Skip to content
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

Move Mongo submission access code to kobocat_backend #1686

Closed
3 tasks done
jnm opened this issue Mar 26, 2018 · 0 comments
Closed
3 tasks done

Move Mongo submission access code to kobocat_backend #1686

jnm opened this issue Mar 26, 2018 · 0 comments
Assignees
Labels
enhancement Ideas, improvements and features

Comments

@jnm
Copy link
Member

jnm commented Mar 26, 2018

Move this:

def get_instances_for_userform_id(userform_id, submission=None):
query = {'_userform_id': userform_id, '_deleted_at': {'$exists': False}}
if submission:
query['_id'] = submission
instances = settings.MONGO_DB.instances.find(query)
return (
MongoDecodingHelper.to_readable_dict(instance)
for instance in instances
)

...to https://github.com/kobotoolbox/kpi/blob/7a306680a7c7f34490d5eb95e6d0c1646fc02a3b/kpi/deployment_backends/kobocat_backend.py

MockDeploymentBackend has a _get_submissions() method; perhaps KobocatDeploymentBackend should have one as well (but why is it marked private?):

def _get_submissions(self):
return self.asset._deployment_data.get('submissions', [])

Requirements for submission data access (could be spread across multiple methods):

  • Ability to get individual submissions
  • read json from mongo and decode it (or, certainly decode it before sending to an external REST server, if there’s some reason not to always decode it as soon as it’s read from Mongo)
  • read xml from postgres (readonlyinstance)
@jnm jnm added the enhancement Ideas, improvements and features label Mar 26, 2018
@jnm jnm added this to the UNHCR REST Services milestone Mar 26, 2018
@jnm jnm closed this as completed in #1864 Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Ideas, improvements and features
Projects
None yet
Development

No branches or pull requests

2 participants