-
-
Notifications
You must be signed in to change notification settings - Fork 695
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
Allow to set facets_array
in metadata (like current facets
)
#1552
Comments
This is definitely a missing feature. The "different types of facet" stuff feels incomplete to me generally - this is one issue, but this one as well: |
@simonw thank you for your fast answer and your guidance! While digging into the code, I found an undocumented way of doing it: facets: ["Facet for a column", {"array": "Facet for an array"}] The only remaining problem with that solution is here: Line 33 in 250db81
We have: type, metadata_config = metadata_config.items()[0] But it requires to cast the type, metadata_config = list(metadata_config.items())[0] I guess it's an unspotted bug? (I mean, independently of the facets-with-arrays issue.) |
I think you're right! I had completely forgotten that piece of code. This just turned into a bug fix and a documentation update. Thanks for the research! |
I tried that fix you suggested and now this {
"databases": {
"fixtures": {
"tables": {
"facetable": {
"facets": [
{
"array": "tags"
}
]
}
}
}
}
} It does further highlight the bug in #625 though - since then if you try to add |
I'm also not convinced that this configuration syntax is right. It's a bit weird having a Part of the problem here is that facets were designed to accept optional extra configuration - partly to support Facet by delimiter would be a good one to exercise that ability: |
I'm going to ship your fix now, but I'm not going to add this to the documentation yet because I hope to improve the design prior to Datasette 1.0. |
... actually no, I WILL document this, because not documenting this is what got us to this point in the first place! |
Wow, that was fast, thank you so much @simonw !
I agree that it's not ideal, my initial naive approach was to detect if it's an array, like what is done here: Lines 312 to 313 in 2c07327
But it requires an extra query to determine the type, which is a bit problematic, especially for big tables I guess. Taking a look at #510, I wonder if a To be consistent with the Throwing a lot of ideas without knowing the big picture… but sometimes newcomers have superpowers :). |
For now, you can set a
facets
value (array) in your metadata file but I couldn't find a way to set afacets_array
in order to provide default facets for arrays (like tags). My use-case is to access to that kind of view by default without URL's parameters as with other default facets.I'm new to datasette, and I'm willing to help with a PR if that is not already implemented and I missed it!
The text was updated successfully, but these errors were encountered: