From 79d70c00288404fe6c7f9262a198863675c14c37 Mon Sep 17 00:00:00 2001 From: Niraj Adhikari Date: Mon, 4 Sep 2023 12:01:56 +0545 Subject: [PATCH] filters added for the submissions --- osm_fieldwork/OdkCentral.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/osm_fieldwork/OdkCentral.py b/osm_fieldwork/OdkCentral.py index 46d4cdc9..3759664f 100755 --- a/osm_fieldwork/OdkCentral.py +++ b/osm_fieldwork/OdkCentral.py @@ -52,7 +52,8 @@ def downloadThread( project_id: int, xforms: list, - odk_credentials: dict + odk_credentials: dict, + filters: dict = None ): """ Download a list of submissions from ODK Central @@ -75,8 +76,8 @@ def downloadThread( odk_credentials["user"], odk_credentials["passwd"] ) - submissions = form.getSubmissions(project_id, task, 0, False, True) - subs = form.listSubmissions(project_id, task) + # submissions = form.getSubmissions(project_id, task, 0, False, True) + subs = form.listSubmissions(project_id, task, filters) if type(subs) == dict: log.error(f"{subs['message']}, {subs['code']} ") continue @@ -419,6 +420,7 @@ def listForms(self, def getAllSubmissions(self, project_id: int, xforms: list = None, + filters: dict = None ): """ Fetch a list of submissions in a project on an ODK Central server. @@ -463,7 +465,7 @@ def getAllSubmissions(self, for current in cycle: if previous == current: continue - result = executor.submit(downloadThread, project_id, xforms[previous:current], odk_credentials) + result = executor.submit(downloadThread, project_id, xforms[previous:current], odk_credentials, filters) previous = current futures.append(result) for future in concurrent.futures.as_completed(futures): @@ -671,6 +673,7 @@ def listSubmissionBasicInfo(self, def listSubmissions(self, projectId: int, xform: str, + filters: dict = None ): """ Fetch a list of submission instances for a given form. @@ -683,7 +686,7 @@ def listSubmissions(self, (list): The list of Submissions """ url = f"{self.base}projects/{projectId}/forms/{xform}.svc/Submissions" - result = self.session.get(url, auth=self.auth, verify=self.verify) + result = self.session.get(url, auth=self.auth, params=filters, verify=self.verify) if result.ok: self.submissions = result.json() return self.submissions['value']