OpenFn / OpenFn/adaptors

ODK: make it easy to filter submissions by date

Open
#657 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

DevX
Dominant language
JavaScript
Stars
24
Forks
41
Avg merge
3d 13h
Merged PRs (30d)
12

Description

In ODK, when fetching submissions, it's often useful to get by date - particularly when running a cron job.

Users need to build a query like:

$filter=$root/Submissions/__system/submissionDate gt 2020-01-31T23:59:59.999Z 

Which is a lot of typing for a common use case!

A couple of thoughts:

  • We could have a shortcut filter query. Like you can pass { $filter: <date> } today, but maybe we could have openfn-specific query keys, like since (returns submissions since that date). $ query params would map to odk directly, while others would be utilities provided by openfn. We may have to support multiple filters in this approach (if that's even possible)
  • We could provide shortcuts to fields, so maybe $filter=submissionDate gt 2020-01-31T23:59:59.999Z could "expand" to $filter=$root/Submissions/__system/submissionDate gt 2020-01-31T23:59:59.999Z . I don't know if we can automatically just prefix all fields with the $root path or if we need to provide explicit mappings

This would certainly be a lovely API:

getSubmissions(66, form2, { since: $.cursor })

Where cursor is set on input state or the last cron job.

The solution would like require the common cursor so probably needs an example or two somewhere (overview, readme or jsdoc)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the ODK adaptor entry point for getSubmissions and reading how its existing filter query is passed through. Define the supported date shortcut and cursor behavior, then add the requested documentation example and tests showing that the shortcut produces the intended submission-date filtering.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.