html_url,issue_url,id,node_id,user,user_label,created_at,updated_at,author_association,body,reactions,issue,issue_label,performed_via_github_app https://github.com/simonw/datasette/issues/429#issuecomment-482638695,https://api.github.com/repos/simonw/datasette/issues/429,482638695,MDEyOklzc3VlQ29tbWVudDQ4MjYzODY5NQ==,9599,simonw,2019-04-12T16:29:25Z,2019-04-13T01:14:17Z,OWNER,"Getting a prototype working was hardly any code at all: http://127.0.0.1:8001/fixtures/facetable?_where=city_id+in+(select+id+from+facet_cities+where+name+like+%22%25an%25%22) ``` diff --git a/datasette/views/table.py b/datasette/views/table.py index b7c9a4b..7ca9572 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -295,6 +295,10 @@ class TableView(RowTableShared): filters = Filters(sorted(other_args.items()), units, ureg) where_clauses, params = filters.build_where_clauses(table) + # Add _where= from querystring + if self.ds.config(""allow_sql"") and ""_where"" in request.args: + where_clauses.extend(request.args[""_where""]) + # _search support: fts_table = special_args.get(""_fts_table"") fts_table = fts_table or table_metadata.get(""fts_table"") ``` Still needed: - [x] Unit tests - [x] Probably some kind of visual display on the table page so you know that extra clauses have been added (and maybe a UI for dropping them again) I'm going to leave the `:named` parameter support out of the first version of this feature.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",432636432,?_where=sql-fragment parameter for table views, https://github.com/simonw/datasette/issues/429#issuecomment-482766801,https://api.github.com/repos/simonw/datasette/issues/429,482766801,MDEyOklzc3VlQ29tbWVudDQ4Mjc2NjgwMQ==,9599,simonw,2019-04-13T01:56:19Z,2019-04-13T01:56:19Z,OWNER,"Documentation is here: https://datasette.readthedocs.io/en/latest/json_api.html#special-table-arguments Demo: * https://latest.datasette.io/fixtures/facetable?_where=state=%22MI%22&_where=city_id=3 * https://latest.datasette.io/fixtures/facetable?_where=city_id%20in%20(select%20id%20from%20facet_cities%20where%20name%20!=%20%22Detroit%22)","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",432636432,?_where=sql-fragment parameter for table views, https://github.com/simonw/datasette/issues/427#issuecomment-482864457,https://api.github.com/repos/simonw/datasette/issues/427,482864457,MDEyOklzc3VlQ29tbWVudDQ4Mjg2NDQ1Nw==,9599,simonw,2019-04-13T18:51:44Z,2019-04-13T18:57:51Z,OWNER,"A facet needs to: - given a sql query and a list of configs, return a list of buckets - Know how to generate URLs for selecting and deselecting a filter (along with underlying filter application sql logic) - Tell if a specific filter is currently selected or not - Set a time limit and report if it times out - Generate human readable labels - In some cases: expand foreign keys - which means they need access to foreign key information - just the name of the table and the name of the column is enough to call `expand_foreign_keys()` (I [moved that](https://github.com/simonw/datasette/commit/274ef43bb7b129ddc2e68805b4f4ff3776fb9503) to the Datasette class to make it easier to access) - Make suggestions for facets. Let's give it access to the whole table here so it could either run against each column in return and rely with a list of suggestions or it could spot eg a latitude and a longitude column","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",431800286,"New design for facet abstraction, including querystring and metadata.json", https://github.com/simonw/datasette/issues/427#issuecomment-482864837,https://api.github.com/repos/simonw/datasette/issues/427,482864837,MDEyOklzc3VlQ29tbWVudDQ4Mjg2NDgzNw==,9599,simonw,2019-04-13T18:53:43Z,2019-04-13T18:53:43Z,OWNER,"`TableView.data` is currently the longest, hairiest method in the codebase. It's 775 - 177 = 598 lines of code! Extracting faceting logic should help reduce that quite a bit. https://github.com/simonw/datasette/blob/274ef43bb7b129ddc2e68805b4f4ff3776fb9503/datasette/views/table.py#L177-L775","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",431800286,"New design for facet abstraction, including querystring and metadata.json", https://github.com/simonw/datasette/issues/427#issuecomment-482865424,https://api.github.com/repos/simonw/datasette/issues/427,482865424,MDEyOklzc3VlQ29tbWVudDQ4Mjg2NTQyNA==,9599,simonw,2019-04-13T18:56:25Z,2019-04-13T19:42:08Z,OWNER,"I think there's a `Facet` base class. `class ColumnFacet(Facet):` is the default behaviour we have today `class ArrayFacet(Facet):` facet by JSON array `class ManyToManyFacet(Facet):` facet by M2M table `class DateFacet(Facet):` facet by date `class DateTimeFacet(Facet):` facet by datetime `class EmojiFacet(Facet):` super-fun demo plugin I have planned Could even have a facet against a numerical column which loads the entire set of column values into numpy or pandas and calculates complex statistics facets in memory . There’s actually a lot of potential for Datasette plugins that load several MBs of data and analyze using other Python libraries.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",431800286,"New design for facet abstraction, including querystring and metadata.json", https://github.com/simonw/datasette/issues/431#issuecomment-482872210,https://api.github.com/repos/simonw/datasette/issues/431,482872210,MDEyOklzc3VlQ29tbWVudDQ4Mjg3MjIxMA==,9599,simonw,2019-04-13T19:37:57Z,2019-04-13T19:37:57Z,OWNER,"You should be able to see the reload happening in the console logs: I'm doing some work at the moment to handle mutating files MUCH better - #419 - my goal is to have Datasette work against SQLite files that are being updated out-of-the box, and change the current immutable behaviour to be an option rather than the default.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",432870248,Datasette doesn't reload when database file changes, https://github.com/simonw/datasette/pull/432#issuecomment-482876432,https://api.github.com/repos/simonw/datasette/issues/432,482876432,MDEyOklzc3VlQ29tbWVudDQ4Mjg3NjQzMg==,9599,simonw,2019-04-13T20:06:32Z,2019-04-13T20:06:32Z,OWNER,"This has a bug which isn't being caught by the unit tests (yet) - facet suggestion suggests facets that have already been enabled: There is also a test failure due to missing plugin hook documentation.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",432893491,"Refactor facets to a class and new plugin, refs #427",