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= feature improvements #150

Closed
3 tasks
simonw opened this issue Nov 24, 2017 · 3 comments
Closed
3 tasks

_group_count= feature improvements #150

simonw opened this issue Nov 24, 2017 · 3 comments

Comments

@simonw
Copy link
Owner

simonw commented Nov 24, 2017

  • The "apply filters" form should keep you on the _group_count= page
  • Foreign key references should be expand
  • Page title should reflect the view you are on
@simonw simonw added this to the Advanced JSON edition milestone Dec 10, 2017
@simonw
Copy link
Owner Author

simonw commented Apr 8, 2018

The single biggest challenge here is expanding foreign key references. This is the blocker that prevents _group_count from being useful at the moment.

@simonw
Copy link
Owner Author

simonw commented Apr 8, 2018

From a code point of view, the current mechanism for _group_count makes the TableView even more complicated:

datasette/datasette/app.py

Lines 644 to 653 in 446d47f

# _group_count=col1&_group_count=col2
group_count = special_args_lists.get('_group_count') or []
if group_count:
count_sql = None
sql = 'select {group_cols}, count(*) as "count" from {table_name} {where} group by {group_cols} order by "count" desc limit 100'.format(
group_cols=', '.join('"{}"'.format(group_count_col) for group_count_col in group_count),
table_name=escape_sqlite(table),
where=where_clause,
)
is_view = True

Instead, I think if _group_count is detected we should generate the SQL and then defer to self.custom_sql, like we do for canned queries:

datasette/datasette/app.py

Lines 539 to 541 in 446d47f

canned_query = self.ds.get_canned_query(name, table)
if canned_query is not None:
return await self.custom_sql(request, name, hash, canned_query['sql'], editable=False, canned_query=table)

@simonw
Copy link
Owner Author

simonw commented May 28, 2018

Closing this as obsolete since we have facets now.

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

1 participant