Respect metadata-defined facet ordering in sorted_facet_results#2648
Merged
Respect metadata-defined facet ordering in sorted_facet_results#2648
Conversation
When facets are explicitly defined in table metadata/config, they now appear in the order specified in the configuration rather than being sorted by result count. Request-added facets still appear after metadata-defined facets, sorted by count as before. https://claude.ai/code/session_01PbSHtjsUpNk3Fx7xjvVqDb
Owner
Author
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2648 +/- ##
==========================================
+ Coverage 90.44% 90.46% +0.02%
==========================================
Files 52 52
Lines 8018 8036 +18
==========================================
+ Hits 7252 7270 +18
Misses 766 766 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(I pasted in the issue body text from #2647)
Summary
This change ensures that facets defined in table metadata are returned in their configured order, rather than being sorted by result count and name. Request-based facets (added via
_facetparameter) are still sorted by result count and appear after metadata-defined facets.Key Changes
extra_sorted_facet_results()indatasette/views/table.pyto parse facet configurations from table metadata and maintain their defined ordertests/test_facets.py:test_other_types_of_facet_in_metadata()to verify facets appear in metadata-defined order in HTML responsestest_metadata_facet_ordering()to verify JSON response ordering for both metadata-only and mixed metadata/request-based facetsImplementation Details
"state") and dict format ({"date": "created"}) for facet definitionshttps://claude.ai/code/session_01PbSHtjsUpNk3Fx7xjvVqDb