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

?_group_count=country - return counts by specific column(s) #44

Closed
1 of 3 tasks
simonw opened this issue Oct 30, 2017 · 7 comments
Closed
1 of 3 tasks

?_group_count=country - return counts by specific column(s) #44

simonw opened this issue Oct 30, 2017 · 7 comments
Labels

Comments

@simonw
Copy link
Owner

simonw commented Oct 30, 2017

Imagine if this:

https://stateless-datasets-jykibytogk.now.sh/flights-07d1283/airports.jsono?country__contains=gu&_group_count=country

Turned into this:

https://stateless-datasets-jykibytogk.now.sh/flights-07d1283?sql=select%20country,%20count(*)%20as%20group_count_country%20from%20airports%20where%20country%20like%20%27%gu%%27%20group%20by%20country%20order%20by%20group_count_country%20desc

This would involve introducing a new precedent of query string arguments that start with an _ having special meanings. While we're at it, could try adding _fields=x,y,z

Tasks:

  • Get initial version working
  • Refactor code to not just "pretend to be a view"
  • Get foreign key relationships expanded
@simonw simonw added the small label Oct 30, 2017
@simonw simonw added this to the v1 stretch goals milestone Oct 30, 2017
@simonw
Copy link
Owner Author

simonw commented Nov 7, 2017

I’m going to call this feature “count values”

@simonw simonw modified the milestones: v1 stretch goals, v2: visualization edition Nov 14, 2017
@simonw
Copy link
Owner Author

simonw commented Nov 17, 2017

This should support multiple columns, e.g. ?_group_count=precinct&_group_count=candidate

@simonw
Copy link
Owner Author

simonw commented Nov 17, 2017

Should this support sum/avg/etc as well?

@simonw
Copy link
Owner Author

simonw commented Nov 19, 2017

It would be great if this could support foreign key references and automatically resolve and hyperlink them if they are detected.

@simonw simonw modified the milestones: v2: visualization edition, Foreign key edition Nov 19, 2017
@simonw
Copy link
Owner Author

simonw commented Nov 19, 2017

This would enable faceted search - moving it to the search milestone.

@simonw simonw modified the milestones: Foreign key edition, SQLite extensions, advanced JSON and FTS search edition Nov 19, 2017
simonw added a commit that referenced this issue Nov 20, 2017
URL shortcut for counting rows grouped by one or more columns.

?_group_count=column1&_group_count=column2 works as well.

SQL generated looks like this:

    select "qSpecies", count(*) as "count"
    from Street_Tree_List
    group by "qSpecies"
    order by "count" desc limit 100

Or for two columns like this:

    select "qSpecies", "qSiteInfo", count(*) as "count"
    from Street_Tree_List
    group by "qSpecies", "qSiteInfo"
    order by "count" desc limit 100

Refs #44

Still todo: clean up code a bunch (it currently fakes being a 'view'), get
foreign key expansion working.
@simonw simonw changed the title Idea: ?_group_count=country to return counts by a specific column ?_group_count=country - return counts by specific column(s) Nov 20, 2017
@simonw simonw modified the milestone: Advanced JSON edition Dec 10, 2017
@simonw
Copy link
Owner Author

simonw commented Apr 26, 2018

Remaining work for this is tracked in #150

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