Skip to content

Commit

Permalink
CSCFAIRMETA-1416: Retrieve only required research_dataset fields in d…
Browse files Browse the repository at this point in the history
…ataset list
  • Loading branch information
tahme committed Mar 31, 2022
1 parent fa7e04a commit 9cd92de
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions etsin_finder/services/qvain_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class MetaxQvainAPIService(BaseService, ConfigValidationMixin):

schema = MetaxServiceConfigurationSchema(unknown=marshmallow.RAISE)

DATASETS_RESEARCH_DATASET_FIELDS = 'title,preferred_identifier'

@property
def config(self):
"""Get service configuration"""
Expand Down Expand Up @@ -84,7 +86,7 @@ def _METAX_GET_DATASETS_FOR_USER(self):
def _METAX_GET_ALL_DATASETS_FOR_USER(self):
return (
self.metax_url("/rest/v2/datasets")
+ "?metadata_provider_user={0}&no_pagination=true&ordering=-date_created"
+ "?metadata_provider_user={0}&pagination=false&ordering=-date_created"
)

@property
Expand Down Expand Up @@ -271,7 +273,9 @@ def get_datasets_for_user(
if no_pagination:
req_url = format_url(self._METAX_GET_ALL_DATASETS_FOR_USER, user_id)

params = {}
params = {
"research_dataset_fields": self.DATASETS_RESEARCH_DATASET_FIELDS,
}
if limit:
params["limit"] = limit
if offset:
Expand Down Expand Up @@ -300,7 +304,10 @@ def get_datasets_for_editor(self, user_id, data_catalog_matcher=None):
"""
req_url = format_url(self._METAX_GET_ALL_DATASETS_FOR_EDITOR, user_id)

params = {"pagination": "false"}
params = {
"pagination": "false",
"research_dataset_fields": self.DATASETS_RESEARCH_DATASET_FIELDS,
}
if data_catalog_matcher:
params["data_catalog"] = data_catalog_matcher

Expand All @@ -327,7 +334,10 @@ def get_datasets_for_projects(self, projects, data_catalog_matcher=None):
self._METAX_GET_ALL_DATASETS_FOR_PROJECTS, ",".join(projects)
)

params = {"pagination": "false"}
params = {
"pagination": "false",
"research_dataset_fields": self.DATASETS_RESEARCH_DATASET_FIELDS,
}
if data_catalog_matcher:
params["data_catalog"] = data_catalog_matcher

Expand Down

0 comments on commit 9cd92de

Please sign in to comment.