Sage-Bionetworks / sage-monorepo

Where OpenChallenges, Schematic, and other Sage open source apps are built
https://sage-bionetworks.github.io/sage-monorepo/
Apache License 2.0
21 stars 12 forks source link

feat(openchallenges): filter platform, edam concept, organization by ids/slugs (backend) #2675

Closed rrchai closed 1 month ago

rrchai commented 1 month ago

Preview

Filter EDAM by Ids

GET {{basePath}}/edamConcepts?ids=1,100

HTTP/1.1 200 
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Type: application/json
Transfer-Encoding: chunked
Date: Tue, 14 May 2024 13:27:31 GMT
Connection: close

{
  "number": 0,
  "size": 100,
  "totalElements": 2,
  "totalPages": 1,
  "hasNext": false,
  "hasPrevious": false,
  "edamConcepts": [
    {
      "id": 100,
      "classId": "http://edamontology.org/data_0941",
      "preferredLabel": "Electron microscopy model"
    },
    {
      "id": 1,
      "classId": "http://edamontology.org/data_0005",
      "preferredLabel": "Resource type"
    }
  ]
}

Filter Platforms by slugs

GET {{basePath}}/challengePlatforms?slugs=synapse,kaggle

HTTP/1.1 200 
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Type: application/json
Transfer-Encoding: chunked
Date: Tue, 14 May 2024 22:22:28 GMT
Connection: close

{
  "number": 0,
  "size": 100,
  "totalElements": 2,
  "totalPages": 1,
  "hasNext": false,
  "hasPrevious": false,
  "challengePlatforms": [
    {
      "id": 8,
      "slug": "kaggle",
      "name": "Kaggle",
      "avatarUrl": "",
      "websiteUrl": "https://www.kaggle.com/",
      "createdAt": "2023-08-09T23:01:32Z",
      "updatedAt": "2023-10-19T21:50:28Z"
    },
    {
      "id": 1,
      "slug": "synapse",
      "name": "Synapse",
      "avatarUrl": "",
      "websiteUrl": "https://synapse.org/",
      "createdAt": "2023-08-09T23:01:32Z",
      "updatedAt": "2023-11-21T01:07:14Z"
    }
  ]
}

Filter organizations by Ids

GET {{basePath}}/organizations?ids=1,100

HTTP/1.1 200 
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Type: application/json
Transfer-Encoding: chunked
Date: Tue, 14 May 2024 22:20:03 GMT
Connection: close

{
  "number": 0,
  "size": 100,
  "totalElements": 2,
  "totalPages": 1,
  "hasNext": false,
  "hasPrevious": false,
  "organizations": [
    {
      "id": 1,
      "name": "Dialogue on Reverse Engineering Assessment and Methods",
      "login": "dream",
      "description": "DREAM Challenges use crowd-sourcing to solve complex biomedical research questions.  Together, we share a vision to enable individuals and groups to collaborate openly so that the “wisdom of the crowd” provides the greatest impact on science and human health.",
      "avatarKey": "logo/dream.png",
      "websiteUrl": "https://dreamchallenges.org/",
      "challengeCount": 73,
      "createdAt": "2023-08-04T07:33:09Z",
      "updatedAt": "2023-11-21T01:18:41Z",
      "acronym": "DREAM"
    },
    {
      "id": 100,
      "name": "International Flavors and Fragrances Inc.",
      "login": "iff",
      "description": "We apply science and creativity for a better world.  With the beauty of art and the precision of science, we are an international collective of thinkers who partner with customers to bring scents, tastes, experiences, ingredients and solutions for products the world craves.  As a global leader in food, beverage, health, biosciences and sensorial experiences, we do a lot and continually innovate to do it better.  For more than 130 years we've been focused on finding the most innovative solutions to help bring “better for you” products to market. While we have grown over the years, we remain agile in our approach and put our customers' needs at the forefront of our thinking.  We offer end-to-end service that few can deliver on. Our unparalleled product portfolio is the most robust in the industry and we have leadership positions across key taste, texture, scent, nutrition, enzymes, cultures, soy proteins and probiotics categories.",
      "avatarKey": "logo/iff.png",
      "websiteUrl": "https://www.iff.com/",
      "challengeCount": 1,
      "createdAt": "2023-06-23T00:00:00Z",
      "updatedAt": "2023-07-26T20:14:38Z",
      "acronym": "IFF"
    }
  ]
}
rrchai commented 1 month ago

I only make it work for filtering EDAM concepts by Ids, but negative on organizations and platforms.

GET {{basePath}}/edamConcepts?ids=1,100

HTTP/1.1 200 
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Type: application/json
Transfer-Encoding: chunked
Date: Tue, 14 May 2024 13:27:31 GMT
Connection: close

{
  "number": 0,
  "size": 100,
  "totalElements": 2,
  "totalPages": 1,
  "hasNext": false,
  "hasPrevious": false,
  "edamConcepts": [
    {
      "id": 100,
      "classId": "http://edamontology.org/data_0941",
      "preferredLabel": "Electron microscopy model"
    },
    {
      "id": 1,
      "classId": "http://edamontology.org/data_0005",
      "preferredLabel": "Resource type"
    }
  ]
}

Errors for failed attempts

GET {{basePath}}/challengePlatforms?slugs=synapse,kaggle
2024-05-14 13:21:29 INFO  [http-nio-8085-exec-1] o.s.o.c.s.service.ChallengeService - challengeEntitiesPage Page 1 of 6 containing org.sagebionetworks.openchallenges.challenge.service.model.entity.ChallengeEntity instances
2024-05-14 13:21:43 INFO  [http-nio-8085-exec-2] o.s.o.c.s.s.ChallengePlatformService - query class ChallengePlatformSearchQueryDto {
    pageNumber: 0
    pageSize: 100
    sort: relevance
    direction: null
    slugs: [synapse, kaggle]
    searchTerms: null
}
2024-05-14 13:21:43 WARN  [http-nio-8085-exec-2] o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - Resolved [org.hibernate.search.util.common.SearchException: HSEARCH000610: Unknown field 'slug'.<EOL>Context: indexes [openchallenges-challenge-platform]]
# no error, or results
GET {{basePath}}/organizations?ids=1,100

HTTP/1.1 200 
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Type: application/json
Transfer-Encoding: chunked
Date: Tue, 14 May 2024 13:30:24 GMT
Connection: close

{
  "number": 0,
  "size": 100,
  "totalElements": 0,
  "totalPages": 0,
  "hasNext": false,
  "hasPrevious": false,
  "organizations": []
}

Update:

The errors are resolved by adding index either by KeywordField for slug (exact matched on string) or GenericField for id.

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed for 'openchallenges-app'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed for 'openchallenges-challenge-service'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed for 'openchallenges-image-service'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed for 'openchallenges-organization-service'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud