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

Count queries #29

Closed
rufuspollock opened this issue Aug 27, 2011 · 5 comments
Closed

Count queries #29

rufuspollock opened this issue Aug 27, 2011 · 5 comments
Assignees
Milestone

Comments

@rufuspollock
Copy link
Member

I want a way to just get back a total count for a given query:

{db}/{table}/?query-stuff&_count=1

Could change so total/count is returned on every query but this would require result set object to change from just being a list of results to something like:

{
  count: ...
  results:
}

IMO you are probably going to want something like this going forward anyway but that is just my 2c.

Details

  • count: Always present
  • Null by default unless requested by _count parameter

Update or json and html view (no change to csv). Change re json format is already part of #40.

@ghost ghost assigned pudo Aug 27, 2011
@pudo
Copy link
Contributor

pudo commented Aug 27, 2011

Most queries in webstore have an "X-Count" header, just pass along _limit=0 to get the count only.

TODO here is to make sure the raw SQL endpoint has it.

@rufuspollock
Copy link
Member Author

OK. Couldn't see this anywhere in the docs hence the ticket :-)

Have to say X-Count header does not seem the most helpful method -- e.g. means that in javascript i have do do something special with my jqXHR object to get at headers rather than processing the usual returned json data.

I'm wondering whether all of this is pointing to thinking of a slightly more general response format (think of the response objects from sqlalchemy queries).

@pudo
Copy link
Contributor

pudo commented Aug 29, 2011

As mentioned during our skype conversation yesterday, I'm still hesistant to adopt a proper results format: this would kill the easy transition from export to API which I think is the key to making this thing useful.

If needed, I think _count=true may be the better option.

@kindly
Copy link
Contributor

kindly commented Nov 3, 2011

We accept _count=true and _count=1. Counting will only happen then and the header nor the json will be populated otherwise.

@kindly kindly closed this as completed Nov 3, 2011
@rufuspollock
Copy link
Member Author

@kindly: I thought plan was for count to always be in results but to be null if not computed. I think this is nicer. For HTML I'm less sure but for simplicity it would be the same. That said this does not seem to matter much either way ...

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

No branches or pull requests

3 participants