{"html_url": "https://github.com/simonw/datasette/pull/2052#issuecomment-1546362374", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2052", "id": 1546362374, "node_id": "IC_kwDOBm6k_c5cK54G", "user": {"value": 9020979, "label": "hydrosquall"}, "created_at": "2023-05-12T22:09:03Z", "updated_at": "2023-05-12T22:09:03Z", "author_association": "NONE", "body": "Hey @cldellow , thanks for the thoughtful feedback and describing the \"lazy facets\" feature! \r\n\r\nIt sounds like the [postTask](https://developer.mozilla.org/en-US/docs/Web/API/Scheduler/postTask) API might be relevant for the types of network request scheduling you have in mind. \r\n\r\nAddressing your points inline below:\r\n\r\n> It might also be nice if the plugins could return Promises.\r\n\r\nWere you picturing that the whole plugin config object could be returned as a promise, or that the individual hooks (like `makeColumnActions` or `makeAboveTablePanelConfigs` supported returning a promise of arrays instead only returning plain arrays?\r\n\r\nI think what you're describing can be achievable, but I want to make sure I do so in a way that addresses your need / keeps the complexity of the plugin core system at a level this is approachable . \r\n\r\nI have a hunch that what you're describing might be achievable without adding Promises to the API with something like\r\n\r\n```\r\nfetch('/api/with-custom-facets').then(myFacets => {\r\n // reusing the go() idiom\r\n go(manager, myFacets);\r\n})\r\n```\r\n\r\nbut I'd like to confirm if that's the case before investigating adding support.\r\n\r\n> bulletproof plugin registration code that is robust against the order in which the script tags load\r\n\r\nYes, I think what you wrote looks right to me! While it looks a little bit verbose compared to the second example, I'm hoping we can mitigate the cost of that during this API incubation phase by making it an easy-to-copy paste code snippet.\r\n\r\nI haven't heard of the GA queing pattern before, thanks for the example. I won't have time to implement of proof of concept in the next few weeks, but I took some time to think through the pros/cons to decide whether we may want to add this in a future release:\r\n\r\nI can see that this approach brings advantages\r\n\r\n- Plugin developers don't need to know the name of the datasette initialization event to start their plugin\r\n- Pushing a function to an array probably is easier (definitely more concise) than adding a document event listener\r\n- One less event listener sitting in memory\r\n\r\nIt also has some minor costs\r\n\r\n- A malicious plugin could choose to (or accidentally) mess with the order of the queue if multiple scripts are lined up\r\n- Some risk in encouraging people to mutate global state\r\n- (not a cost, more a moot point): changing this API may not make a meaningful difference if we're discussing whether people enter 2 vs 5 lines of code, especially if those lines are encapsulated by a function we provide (maybe something that's available on the `window` provided by Datasette as an inline script tag). \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": 1651082214, "label": "feat: Javascript Plugin API (Custom panels, column menu items with JS actions)"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2073#issuecomment-1546117538", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2073", "id": 1546117538, "node_id": "IC_kwDOBm6k_c5cJ-Gi", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-05-12T18:21:38Z", "updated_at": "2023-05-12T18:21:38Z", "author_association": "OWNER", "body": "https://latest.datasette.io/fixtures doesn't currently have a view with any integer columns in it, making this bug harder to demonstrate there.\r\n\r\nI can't replicate the bug using https://datasette.io/content/plugins?_facet=stargazers_count&stargazers_count=3 - I would expect that not to work correctly.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1708030220, "label": "Faceting doesn't work against integer columns in views"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2073#issuecomment-1546119773", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2073", "id": 1546119773, "node_id": "IC_kwDOBm6k_c5cJ-pd", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-05-12T18:24:07Z", "updated_at": "2023-05-12T18:24:07Z", "author_association": "OWNER", "body": "Here's a demo of this breaking in Datasette Lite:\r\n\r\nhttps://lite.datasette.io/?sql=https://gist.github.com/simonw/261564c0ca01567df6eeb9b222b8be84&json=https%3A%2F%2Fcdn.jsdelivr.net%2Fnpm%2Fweb-features%2Findex.json#/data/baseline?_filter_column_1=is_baseline&_filter_op_1=exact&_filter_value_1=1&_filter_column_2=&_filter_op_2=notnull__1&_filter_value_2=1&_filter_column=&_filter_op=exact&_filter_value=&_sort=&_facet=is_baseline\r\n\r\n\"image\"\r\n\r\nHere's a SQL query that demonstrates the underlying issue:\r\n\r\n```sql\r\nselect 'working', count(*) from baseline where is_baseline = 1\r\nunion all\r\nselect 'broken', count(*) from baseline where is_baseline = '1'\r\n```\r\nhttps://lite.datasette.io/?sql=https://gist.github.com/simonw/261564c0ca01567df6eeb9b222b8be84&json=https%3A%2F%2Fcdn.jsdelivr.net%2Fnpm%2Fweb-features%2Findex.json#/data?sql=select+%27working%27%2C+count%28*%29+from+baseline+where+is_baseline+%3D+1%0Aunion+all%0Aselect+%27broken%27%2C+count%28*%29+from+baseline+where+is_baseline+%3D+%271%27\r\n\r\n\"image\"", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1708030220, "label": "Faceting doesn't work against integer columns in views"}, "performed_via_github_app": null}