-
-
Notifications
You must be signed in to change notification settings - Fork 697
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
If you apply ?_facet_array=tags then &_facet=tags does nothing #625
Comments
Implementing #1552 has made a fix for this bug even more important. |
I think the problem here may be in the design of the JSON returned by facets. It looks like this:
The problem then is that the https://latest-with-plugins.datasette.io/fixtures/facetable?_trace=1&_facet=created&_facet_date=created&_facet_array=tags&_facet=tags confirms that the SQL queries for those facets are being executed - but the final JSON doesn't show them on https://latest-with-plugins.datasette.io/fixtures/facetable.json?_trace=1&_facet=created&_facet_date=created&_facet_array=tags&_facet=tags They're not available in the template context either: https://latest-with-plugins.datasette.io/fixtures/facetable?_facet=created&_facet_date=created&_facet_array=tags&_facet=tags&_context=1 |
The big question here is do I break any existing clients of the It's still pre-1.0 so I could break them, but I've also built my own code against this in the past so it's likely other people have too. If I don't break them, I will instead need to come up with a naming convention for those keys - something like |
Datasette's own HTML rendering code doesn't actually use the keys in datasette/datasette/views/table.py Lines 937 to 941 in 992496f
And used like this: datasette/datasette/templates/table.html Lines 154 to 156 in 992496f
|
Really |
Decision: as an initial fix I'm going to de-duplicate those keys by using I'll open a separate issue to redesign this better for Datasette 1.0. |
Here's where datasette/datasette/views/table.py Lines 752 to 758 in 992496f
So the decision to key things based on column name is actually embedded deep in the existing facet classes here: Lines 224 to 226 in 992496f
Lines 395 to 397 in 992496f
Lines 510 to 512 in 992496f
|
This bad design is even covered in the plugin hooks documentation: https://docs.datasette.io/en/0.59.4/plugin_hooks.html#register-facet-classes It does at least have the following warning:
|
Good news - GitHub's new code search doesn't show ANYONE using that plugin hook - not surprising since it has that documentation warning plus it's just not a very clearly usable hook: https://cs.github.com/?scopeName=All+repos&scope=&q=register_facet_classes%20-repo%3Asimonw%2Fdatasette |
Since no-one is using that plugin hook I'm going to alter its contract slightly. I'll still keep the existing JSON format working though (until 1.0), since it's much more likely that people are using that JSON somewhere. |
I updated the example code in the facet plugin hook documentation: https://github.com/simonw/datasette/blob/95d0dd7a1cf6be6b7da41e1404184217eb93f64a/docs/plugin_hooks.rst#register_facet_classes |
And here's the new JSON: https://latest.datasette.io/fixtures/facetable.json?_facet=created&_facet_date=created&_facet=tags&_facet_array=tags&_nosuggest=1
|
Start here: https://v0-30-2.datasette.io/fixtures/facetable?_facet_array=tags
Note that
tags
is offered as a suggested facet. But if you click that you get this:https://v0-30-2.datasette.io/fixtures/facetable?_facet_array=tags&_facet=tags
The
_facet=tags
is added to the URL and it's removed from the list of suggested tags... but the facet itself is not displayed:The
_facet=tags
facet should look like this:The text was updated successfully, but these errors were encountered: