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 API to search things better #504

Merged
merged 2 commits into from
Mar 22, 2015
Merged

allow API to search things better #504

merged 2 commits into from
Mar 22, 2015

Conversation

bewest
Copy link
Member

@bewest bewest commented Mar 19, 2015

This allows a query such as this to search for events of hypoglycemia for
example:

curl -g localhost:3434 \
     /api/v1/entries   \
     '?find[sgv][$lte]=70&find[sgv][$gte]=20&count=1000

It's possible to construct most mongo queries by url encoding the query string.
In this instance, mongo performs poorly when searching for lte/gte for strings.
In order for ranged queries to perform properly, the query parameters must be
set to integer type. There is a quick and ugly helper to ensure that some sgv
queries will be respected as integer searches.

This allows a query such as this to search for events of hypoglycemia for
example:
curl -g localhost:3434 \
     /api/v1/entries   \
     '?find[sgv][$lte]=70&find[sgv][$gte]=20&count=1000

It's possible to construct most mongo queries by url encoding the query string.
In this instance, mongo performs poorly when searching for lte/gte for strings.
In order for ranged queries to perform properly, the query parameters must be
set to integer type.  There is a quick and ugly helper to ensure that some sgv
queries will be respected as integer searches.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.24%) to 71.09% when pulling 95746ab on wip/api-params into 5eb51bc on dev.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.24%) to 71.09% when pulling 95746ab on wip/api-params into 5eb51bc on dev.

@bewest
Copy link
Member Author

bewest commented Mar 19, 2015

$ curl -g localhost:3434/api/v1/entries'?find[dateString][$lte]=2015-01-32&find[dateString][$gte]=2015-01-00&count=10000'  | wc -l && echo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  559k    0  559k    0     0   187k      0 --:--:--  0:00:02 --:--:--  187k
9813

@bewest bewest added this to the enchilada milestone Mar 19, 2015
@jasoncalabrese
Copy link
Member

Cool, very useful

@jasoncalabrese
Copy link
Member

Looks like lots of data is getting filtered out, missing cal and sensor entries and fields like unfiltered, filtered, slope, mbg, type, etc, etc

@jasoncalabrese
Copy link
Member

and would be nice if http://localhost:1337/api/v1/entries.json?find[mbg]&count=100 or http://localhost:1337/api/v1/entries.json?find[type][mbg]&count=100 would work

Queries such as: ?find[type]=mbg will now serve responses with payloads with
non-SGV data elements, including mbgs.
In fact, the type query above filters to select only mbg records.
@bewest
Copy link
Member Author

bewest commented Mar 20, 2015

?find[type]=mbg will now search exclusively for mbg records. Also json responses will include mbg and other data elements, so long as they have a type property.

I strongly encourage using iso8601 date encoding to make the date filtering features work with ease.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.24%) to 71.09% when pulling 4f11948 on wip/api-params into 5eb51bc on dev.

@jasoncalabrese
Copy link
Member

I agree on date format, I don't think the api really used yet so it's a good fine to change. Maybe add a param to return UTC timestamps?

@jasoncalabrese
Copy link
Member

Works good should we do something with the date format here (export only) or wait till we do something bigger?

@jasoncalabrese
Copy link
Member

Lets look at date formatting outside of this, going to merge now

jasoncalabrese added a commit that referenced this pull request Mar 22, 2015
allow API to search things better
@jasoncalabrese jasoncalabrese merged commit 8889ceb into dev Mar 22, 2015
@jasoncalabrese jasoncalabrese deleted the wip/api-params branch March 22, 2015 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants