-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMR-10238: Adding the virtual catalog 'ALL' #379
Conversation
…ons/<collection>, ALL/collections/search etc.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #379 +/- ##
==========================================
+ Coverage 88.22% 88.39% +0.17%
==========================================
Files 24 24
Lines 1180 1215 +35
Branches 261 269 +8
==========================================
+ Hits 1041 1074 +33
- Misses 139 141 +2 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
* If the provider is 'ALL', it exits early with a 404. | ||
|
||
*/ | ||
export const validateNotAllProvider = async (req: Request, _res: Response, next: NextFunction) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could combine the logic in here within the existing validateProvider
and just add another branch for the else conditional if (providerId == ALL_PROVIDER.toString()) { next( new ItemNotFound(
This operation is not allowed for the ${ALL_PROVIDER.toString()} Catalog.) ); }
but, I also see the validity in keeping it separate because otherwise it does get a bit unruly. That said it does mean we are passing two very similar validations across the routes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ValidateProvider applies to all routes (except two health routes). ValidateNotAllProvider only applies to some (we do not allow search routes and item routes for the ALL provider) so I don't think we can combine. . This is why I separated them. I think validateProvider is not necessary (see https://bugs.earthdata.nasa.gov/browse/CMR-10264) so we would probably remove that in the future. validateProvider checks to see if the provider exists via a call to CMR and then, if it does, adds it to the request. This decreases the efficiency of a valid call. An invalid provider should be caught at the graphQL call instead imho.
Co-authored-by: Ed Olivares <[email protected]>
@@ -112,6 +119,8 @@ const providerCollections = async ( | |||
); | |||
|
|||
try { | |||
if ("provider" in mergedQuery && mergedQuery.provider == ALL_PROVIDER) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we can simplify the condition by directly comparing mergedQuery.provider to ALL_PROVIDER
if ("provider" in mergedQuery && mergedQuery.provider == ALL_PROVIDER) | |
if (mergedQuery.provider === ALL_PROVIDER) { | |
delete mergedQuery.provider; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I do that (which I did originally) I get the following error:
src/routes/catalog.ts:122:21 - error TS2339: Property 'provider' does not exist on type '{}'.
Other than my latest comments. Looks pretty good. Will you be able to do a team PR and demo the functionality for us? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sent a PM for how to potentially resolve the typing issue though that is a minor point. I tested this locally for a while and did the test in the PR and didn't see any issues
Overview
What is the feature?
Allows users to perform collection searches across all providers.
What is the Solution?
Add the virtual catalog 'ALL' which will return collection inventories without a provider clause in the collection query
What areas of the application does this impact?
Testing
Reproduction steps
{ "rel": "child", "title": "all", "type": "application/json", "href": "https://cmr.sit.earthdata.nasa.gov/stac/ALL" }
{ "rel": "child", "href": "https://cmr.sit.earthdata.nasa.gov/stac/AMD_KOPRI/collections/Test%201_1.2", "title": "\"The Omnivores Dilemma\": The Effect of Autumn Diet on Winter Physiology and Condition of Juvenile Antarctic Krill", "type": "application/json" },
{ "rel": "items", "href": "https://cmr.sit.earthdata.nasa.gov/stac/AMD_KOPRI/collections/Test%201_1.2/items", "type": "application/geo+json", "title": "Collection Items" }
Attachments
Radian Earth integrations:
Checklist