Skip to content

Commit

Permalink
Merge pull request #190 from nrjadkry/fixes
Browse files Browse the repository at this point in the history
filters added for the submissions
  • Loading branch information
robsavoye authored Sep 4, 2023
2 parents a88ba5b + 79d70c0 commit 6fe819c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions osm_fieldwork/OdkCentral.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand All @@ -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']
Expand Down

0 comments on commit 6fe819c

Please sign in to comment.