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

Allow for sets, filters or collections #49

Open
nickevansuk opened this issue May 10, 2017 · 0 comments
Open

Allow for sets, filters or collections #49

nickevansuk opened this issue May 10, 2017 · 0 comments
Labels

Comments

@nickevansuk
Copy link
Contributor

nickevansuk commented May 10, 2017

Proposal

There are some use-cases where a data consumer only wishes to access a subset of the data for a very large dataset.

Example use-cases include:

  • Only sessions starting after a specific date
  • Only specific activities
  • Only specific sites / venues

The most common case is "after a specific date" URL.

Suggested principles

  • The seed URL used to initiate the paging should contain the filter
  • Subsiquent next URLs should contain the same filter data
  • The approach should be stateless

Example approaches

  • Seed URL: /getSessions?filter={startTime: "now"}
  • Next URL: /getSessions?afterTimestamp=1453931101&afterId=c15814e5&filterSet={timestampAtTimeOfFirstFilter="1453931101", filterStartTime=1453931101}
   var query;
   if (queryParams.from) {
        query = Session.query().filter(
            (
                (Session.modified == queryParams.afterTimestamp && Session.id > queryParams.afterId) || Session.modified > queryParams.afterTimestamp
            ) && (
                Session.startTime > filterStartTime || Session.modified >= timestampAtTimeOfFirstFilter
            )
        );
   } else {
       query = Session.query();
   }
   return query.sort([Session.modified, Session.id])

Note that timestampAtTimeOfFirstFilter is calculated from max(timestamp) from the source table. filterStartTime is calculated from the current date of the system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant