From 6d7f9153f413879182263854aebd0d70d75dba09 Mon Sep 17 00:00:00 2001 From: Shekar V Date: Wed, 9 Oct 2024 21:37:57 -0400 Subject: [PATCH 1/2] Added projection kwarg to find_analysis_header --- analysisstore/server/astore.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/analysisstore/server/astore.py b/analysisstore/server/astore.py index 9bf17f7..c415f93 100644 --- a/analysisstore/server/astore.py +++ b/analysisstore/server/astore.py @@ -210,7 +210,8 @@ def _clean_ids(self, cursor): def find_analysis_header(self, **kwargs): """Given a set of parameters, return analysis header(s) that match the provided criteria""" - cur = self.database.analysis_header.find(kwargs).sort([('time', DESCENDING), + projection = kwargs.pop('_projection', None) + cur = self.database.analysis_header.find(kwargs, projection=projection).sort([('time', DESCENDING), ('uid', DESCENDING)]) return self._clean_ids(cur) From df81ab675de45e9da8a986d9989a12191f4d65e2 Mon Sep 17 00:00:00 2001 From: Shekar V Date: Wed, 9 Oct 2024 21:54:06 -0400 Subject: [PATCH 2/2] Remove _id using projection --- analysisstore/server/astore.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/analysisstore/server/astore.py b/analysisstore/server/astore.py index c415f93..6928d77 100644 --- a/analysisstore/server/astore.py +++ b/analysisstore/server/astore.py @@ -210,10 +210,11 @@ def _clean_ids(self, cursor): def find_analysis_header(self, **kwargs): """Given a set of parameters, return analysis header(s) that match the provided criteria""" - projection = kwargs.pop('_projection', None) + projection = kwargs.pop('_projection', {}) + projection.update({"_id": False}) cur = self.database.analysis_header.find(kwargs, projection=projection).sort([('time', DESCENDING), ('uid', DESCENDING)]) - return self._clean_ids(cur) + return list(cur) def find_data_reference_header(self, **kwargs): """Given a set of kwargs in mongo query format, returns a list of data