Comments (11)
Idea 1: could we sniff the values client side to figure out what options to show?
Problem: render_cell
will trip us up. eg we render ["foo", "bar"]
as foo, bar
so we'll have lost the context.
Idea 2: compute minimal summary statistics for every column in every table. Consult this to determine what the valid options are.
Problem: requires write access on the DB at some point. Won't work (I don't think?) for views unless we have a way to plumb that info through.
Ultimately, I think I like idea 2... how hard is it to plumb the view information all the way through? I think that's equivalent to the work in simonw/datasette#1293
from datasette-ui-extras.
For my immediate use case, tables are the most important thing. For tables, we know the exact column name and can consult it to determine options.
For views, we can just do the current logic, which will be wrong in some cases. If/when we can map view columns to table columns, we can improve it down the road.
from datasette-ui-extras.
An idea: sniff the values that pass through render_cell
, jamming them on to the request
object.
Then extra_body_script
can include a stanza that says what the valid options are.
from datasette-ui-extras.
This is bad, of course - it's so far outside of the facet machinery that we won't be able to re-use suggest_facet
.
Hmm... Unless, and bear with me, we do something particularly disgusting, like create a transient in-memory sqlite table, stuff the values into it, then ask each facet implementation to suggest facets.
That's disgusting, I think I love it.
from datasette-ui-extras.
That also protects against non-defensive implementations that might do accidental table scans.
A risk: if there's not enough variety in the first N things, we won't suggest a facet.
I think maybe we should just hardcode the rules.
from datasette-ui-extras.
render_cell
doesn't have access to the request, so this scheme won't work
from datasette-ui-extras.
render_cell
is also kinda poor because it gets invoked 1x per cell, not 1x per row. (Although we could probably use the id
of the row to detect when a new row was passed?)
That's a shame, because this was seeming fairly elegant
How hard would it be to monkey patch Datasette to either pass the request to render_cell, or to stash the rows in the view code?
from datasette-ui-extras.
For table views, there's this function: https://github.com/simonw/datasette/blob/0b4a28691468b5c758df74fa1d72a823813c96bf/datasette/views/table.py#L881, which seems to get a request and a set of rows.
Does that path get hit for views and custom sql queries?
from datasette-ui-extras.
Gets called for views, not for custom sql queries.
You can't facet custom sql queries, so this is OK.
I expect this function will disappear in Simon's rewrite simonw/datasette#1518
That's OK, we can just gracefully degrade until we get a new way to access this data.
from datasette-ui-extras.
oh, duh, that was a change that Simon just made in order to make request visible to render_cell
. Sooo, it's not there currently, which is unfortunate.
from datasette-ui-extras.
patching TableView.data would work, too: https://github.com/simonw/datasette/blame/0b4a28691468b5c758df74fa1d72a823813c96bf/datasette/views/table.py#L204
from datasette-ui-extras.
Related Issues (20)
- don't enable fkey checks on _internal database
- omnisearch fails to redirect row if compound pkey is used HOT 1
- omnisearch can refuse to do string searches if there are a few integers mixed in
- JSONTagsControl: no way to add an item that doesn't exist in autosuggest
- add row: give option to specify pkey if it's a text field without a default
- Datasette 1.0/main compatibility HOT 1
- python windows charset invalid
- Not working with recent releases
- Add the ability to export a mutable database HOT 1
- Autosuggest doesn't work on mobile
- Consider JSON Schema support HOT 1
- Add `dux` command, rename `dedux` to `undux` HOT 1
- view support for omnisearch
- be able to explicitly specify columns for omnisearch
- CHECK (column IS NULL OR column IN (...)) should work HOT 2
- omnisearch: string fkey to table with no label column is omitted
- pysqlite3-binary does not like setting synchronous = NORMAL HOT 1
- dux_stats_column_values `pks` column got double-encoded somehow HOT 2
- investigate sqlite3 vs pysqlite3-binary difference HOT 4
- `dux_pending_rows` trigger can't handle blobs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datasette-ui-extras.