{"html_url": "https://github.com/simonw/datasette/issues/473#issuecomment-996267817", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/473", "id": 996267817, "node_id": "IC_kwDOBm6k_c47Ydcp", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T23:17:52Z", "updated_at": "2021-12-16T23:19:00Z", "author_association": "OWNER", "body": "I revisited this idea in #1518 and came up with a slightly different name and design for the hook:\r\n\r\n```python\r\n@hookspec\r\ndef filters_from_request(request, database, table, datasette):\r\n \"\"\"\r\n Return FilterArguments(\r\n where_clauses=[str, str, str],\r\n params={},\r\n human_descriptions=[str, str, str],\r\n extra_context={}\r\n ) based on the request\"\"\"\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 445850934, "label": "Plugin hook: filters_from_request"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/473#issuecomment-996275108", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/473", "id": 996275108, "node_id": "IC_kwDOBm6k_c47YfOk", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T23:32:22Z", "updated_at": "2021-12-16T23:32:30Z", "author_association": "OWNER", "body": "This filter design can only influence the `where` component of the SQL clause - it's not able to modify the `SELECT` columns or adjust the `ORDER BY` or `OFFSET LIMIT` parts. I think that's OK.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 445850934, "label": "Plugin hook: filters_from_request"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/625#issuecomment-996093884", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/625", "id": 996093884, "node_id": "IC_kwDOBm6k_c47Xy-8", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T19:00:28Z", "updated_at": "2021-12-16T19:00:28Z", "author_association": "OWNER", "body": "Implementing #1552 has made a fix for this bug even more important.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520740741, "label": "If you apply ?_facet_array=tags then &_facet=tags does nothing"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/625#issuecomment-996100774", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/625", "id": 996100774, "node_id": "IC_kwDOBm6k_c47X0qm", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T19:10:01Z", "updated_at": "2021-12-16T19:10:48Z", "author_association": "OWNER", "body": "I think the problem here may be in the design of the JSON returned by facets. It looks like this:\r\n```\r\n \"facet_results\": {\r\n \"tags\": {\r\n \"name\": \"tags\",\r\n \"type\": \"array\",\r\n \"results\": [...],\r\n \"hideable\": false,\r\n \"toggle_url\": \"/fixtures/facetable.json?_facet=tags&_trace=1&_nosuggest=1\",\r\n \"truncated\": false\r\n },\r\n \"created\": {\r\n \"name\": \"created\",\r\n \"type\": \"date\",\r\n \"results\": [...]\r\n```\r\nThe problem then is that the `tags` key is over-ridden by the second facet with a different type against the same column name!\r\n\r\nhttps://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\r\n\r\nThey'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", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520740741, "label": "If you apply ?_facet_array=tags then &_facet=tags does nothing"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/625#issuecomment-996118401", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/625", "id": 996118401, "node_id": "IC_kwDOBm6k_c47X4-B", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T19:34:28Z", "updated_at": "2021-12-16T19:34:55Z", "author_association": "OWNER", "body": "The big question here is do I break any existing clients of the `\"facet_results\"` JSON API?\r\n\r\nIt'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.\r\n\r\nIf I don't break them, I will instead need to come up with a naming convention for those keys - something like `\"tags__array\"` for example. As well as a way to ensure that a column called `tags__array` doesn't end up conflicting with the `tags__array` key!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520740741, "label": "If you apply ?_facet_array=tags then &_facet=tags does nothing"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/625#issuecomment-996119954", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/625", "id": 996119954, "node_id": "IC_kwDOBm6k_c47X5WS", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T19:36:01Z", "updated_at": "2021-12-16T19:36:11Z", "author_association": "OWNER", "body": "Datasette's own HTML rendering code doesn't actually use the keys in `facet_results` - it instead loops through `sorted_facet_results` which is defined like this: https://github.com/simonw/datasette/blob/992496f2611a72bd51e94bfd0b17c1d84e732487/datasette/views/table.py#L937-L941\r\n\r\nAnd used like this:\r\n\r\nhttps://github.com/simonw/datasette/blob/992496f2611a72bd51e94bfd0b17c1d84e732487/datasette/templates/table.html#L154-L156", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520740741, "label": "If you apply ?_facet_array=tags then &_facet=tags does nothing"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/625#issuecomment-996121736", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/625", "id": 996121736, "node_id": "IC_kwDOBm6k_c47X5yI", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T19:37:08Z", "updated_at": "2021-12-16T19:37:08Z", "author_association": "OWNER", "body": "Really `facet_results` here should be an array of objects, not an object that maps poorly designed string keys to those objects.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520740741, "label": "If you apply ?_facet_array=tags then &_facet=tags does nothing"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/625#issuecomment-996130862", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/625", "id": 996130862, "node_id": "IC_kwDOBm6k_c47X8Au", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T19:44:48Z", "updated_at": "2021-12-16T19:44:48Z", "author_association": "OWNER", "body": "Decision: as an initial fix I'm going to de-duplicate those keys by using `tags__array` etc - with a `_2` on the end if that key is already used.\r\n\r\nI'll open a separate issue to redesign this better for Datasette 1.0.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520740741, "label": "If you apply ?_facet_array=tags then &_facet=tags does nothing"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/625#issuecomment-996146762", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/625", "id": 996146762, "node_id": "IC_kwDOBm6k_c47X_5K", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T19:51:44Z", "updated_at": "2021-12-16T19:51:44Z", "author_association": "OWNER", "body": "Here's where `facet_results` is built up: https://github.com/simonw/datasette/blob/992496f2611a72bd51e94bfd0b17c1d84e732487/datasette/views/table.py#L752-L758\r\n\r\nSo the decision to key things based on column name is actually embedded deep in the existing facet classes here:\r\n\r\nhttps://github.com/simonw/datasette/blob/992496f2611a72bd51e94bfd0b17c1d84e732487/datasette/facets.py#L224-L226\r\n\r\nhttps://github.com/simonw/datasette/blob/992496f2611a72bd51e94bfd0b17c1d84e732487/datasette/facets.py#L395-L397\r\n\r\nhttps://github.com/simonw/datasette/blob/992496f2611a72bd51e94bfd0b17c1d84e732487/datasette/facets.py#L510-L512", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520740741, "label": "If you apply ?_facet_array=tags then &_facet=tags does nothing"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/625#issuecomment-996149720", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/625", "id": 996149720, "node_id": "IC_kwDOBm6k_c47YAnY", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T19:56:14Z", "updated_at": "2021-12-16T19:56:14Z", "author_association": "OWNER", "body": "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\r\n\r\nIt does at least have the following warning:\r\n\r\n> **Warning**\r\n>\r\n> The design of this plugin hook is unstable and may change. See [issue 830](https://github.com/simonw/datasette/issues/830).", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520740741, "label": "If you apply ?_facet_array=tags then &_facet=tags does nothing"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/625#issuecomment-996150904", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/625", "id": 996150904, "node_id": "IC_kwDOBm6k_c47YA54", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T19:57:52Z", "updated_at": "2021-12-16T19:57:52Z", "author_association": "OWNER", "body": "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", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520740741, "label": "If you apply ?_facet_array=tags then &_facet=tags does nothing"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/625#issuecomment-996152213", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/625", "id": 996152213, "node_id": "IC_kwDOBm6k_c47YBOV", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T19:59:46Z", "updated_at": "2021-12-16T20:00:05Z", "author_association": "OWNER", "body": "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.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520740741, "label": "If you apply ?_facet_array=tags then &_facet=tags does nothing"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/625#issuecomment-996161380", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/625", "id": 996161380, "node_id": "IC_kwDOBm6k_c47YDdk", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T20:13:05Z", "updated_at": "2021-12-16T20:13:05Z", "author_association": "OWNER", "body": "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", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520740741, "label": "If you apply ?_facet_array=tags then &_facet=tags does nothing"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/625#issuecomment-996165659", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/625", "id": 996165659, "node_id": "IC_kwDOBm6k_c47YEgb", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T20:19:53Z", "updated_at": "2021-12-16T20:19:53Z", "author_association": "OWNER", "body": "Demo of the fix: https://latest.datasette.io/fixtures/facetable?_facet=created&_facet_date=created&_facet=tags&_facet_array=tags#facet-tags", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520740741, "label": "If you apply ?_facet_array=tags then &_facet=tags does nothing"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/625#issuecomment-996170510", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/625", "id": 996170510, "node_id": "IC_kwDOBm6k_c47YFsO", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T20:27:41Z", "updated_at": "2021-12-16T20:27:41Z", "author_association": "OWNER", "body": "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\r\n\r\n```\r\n{\r\n \"database\": \"fixtures\",\r\n \"table\": \"facetable\",\r\n \"is_view\": false,\r\n \"human_description_en\": \"\",\r\n ...\r\n \"facet_results\": {\r\n \"created\": {\r\n \"name\": \"created\",\r\n \"type\": \"column\",\r\n ...\r\n },\r\n \"tags\": {\r\n \"name\": \"tags\",\r\n \"type\": \"column\",\r\n ...\r\n },\r\n \"created_2\": {\r\n \"name\": \"created\",\r\n \"type\": \"date\",\r\n ...\r\n },\r\n \"tags_2\": {\r\n \"name\": \"tags\",\r\n \"type\": \"array\",\r\n ...\r\n }\r\n }\r\n}\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 520740741, "label": "If you apply ?_facet_array=tags then &_facet=tags does nothing"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/830#issuecomment-996151246", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/830", "id": 996151246, "node_id": "IC_kwDOBm6k_c47YA_O", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T19:58:22Z", "updated_at": "2021-12-16T19:58:22Z", "author_association": "OWNER", "body": "As of today, 16 December 2021, I'm still not seeing any evidence that anyone is using this hook (yet) according to GitHub code search: https://cs.github.com/?scopeName=All+repos&scope=&q=register_facet_classes%20-repo%3Asimonw%2Fdatasette", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 636511683, "label": "Redesign register_facet_classes plugin hook"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1518#issuecomment-996219117", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1518", "id": 996219117, "node_id": "IC_kwDOBm6k_c47YRjt", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T21:47:51Z", "updated_at": "2021-12-16T21:49:24Z", "author_association": "OWNER", "body": "Should facets really not be displayed on pages past page one (where `?_next=` is set)? That made sense to me at the time, but I'm now having second thoughts about it.\r\n\r\nI guess it's a useful performance tweak for when crawlers keep hitting the `?_next=` link.\r\n\r\nActually it looks like facets DO display on subsequent pages, e.g. on https://global-power-plants.datasettes.com/global-power-plants/global-power-plants?_next=200 - but facet suggestions do not, thanks to this code: https://github.com/simonw/datasette/blob/2c07327d23d9c5cf939ada9ba4091c1b8b2ba42d/datasette/views/table.py#L777-L785\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1058072543, "label": "Complete refactor of TableView and table.html template"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1518#issuecomment-996225235", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1518", "id": 996225235, "node_id": "IC_kwDOBm6k_c47YTDT", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-12-16T21:58:24Z", "updated_at": "2021-12-16T21:58:41Z", "author_association": "OWNER", "body": "A fundamental operation of this view is to construct the SQL query and accompanying human description based on the incoming query string parameters.\r\n\r\nThe human description is the bit at the top of https://latest.datasette.io/fixtures/searchable?_search=dog&_sort=pk&_facet=text2&text2=sara+weasel that says:\r\n\r\n> 1 row where search matches \"dog\" and text2 = \"sara weasel\" sorted by pk\r\n\r\n(Also used in the page `