-
-
Notifications
You must be signed in to change notification settings - Fork 701
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
"View all" option for facets, to provide a (paginated) list of ALL of the facet counts plus a link to view them #1080
Comments
URL design:
And for other types of facet (to be supported later):
|
Implementing pagination for facets will be interesting. Would be easier if I had a nicer reusable internal pagination mechanism, which is also needed for #856 (pagination of canned queries). |
Maybe this ends up being code that defers to a simulated canned query, rendered using the existing |
For regular column faceting, here's the query that is used: Lines 196 to 204 in 13d1228
Since it uses That wouldn't be robust in the face of changing data, but I'm not sure it's possible to implement paginated faceting in a way that survives ongoing changes to the underlying data. |
Had a new, different idea for how this could work: support a |
An initial prototype of that in my local diff --git a/datasette/views/table.py b/datasette/views/table.py
index be9e9c3..d30efe1 100644
--- a/datasette/views/table.py
+++ b/datasette/views/table.py
@@ -105,8 +105,12 @@ class RowTableShared(DataView):
type_ = "integer"
notnull = 0
else:
- type_ = column_details[r[0]].type
- notnull = column_details[r[0]].notnull
+ try:
+ type_ = column_details[r[0]].type
+ notnull = column_details[r[0]].notnull
+ except KeyError: # Probably count(*)
+ type_ = "integer"
+ notnull = False
columns.append(
{
"name": r[0],
@@ -613,6 +617,15 @@ class TableView(RowTableShared):
offset=offset,
)
+ # If ?_group_count we convert the SQL query here
+ group_count = request.args.getlist("_group_count")
+ if group_count:
+ wrapped_sql = "select {cols}, count(*) from ({sql}) group by {cols}".format(
+ cols=", ".join(group_count),
+ sql=sql,
+ )
+ sql = wrapped_sql
+
if request.args.get("_timelimit"):
extra_args["custom_time_limit"] = int(request.args.get("_timelimit")) Resulted in errors like this one:
|
Can use
/database/-/...
namespace from #296The text was updated successfully, but these errors were encountered: