Repository navigation
feat(smw): server-side default sort (source.orderBy) - #100
Merged
Merged
Conversation
The only lever was initialState.sortModel, which AG Grid applies during init with events suppressed, so the Infinite Row Model's first fetch races ahead unsorted. Mirror Bucket's orderBy instead: { field, direction }, validated at parse time and stored in the query spec. SmwDataSource applies it whenever the request carries no sortModel, via toSortKeys for alias resolution and the subject tiebreaker. A user sort replaces it; clearing the sort falls back to it.
The filterProp heading's hyphen changed its GitHub anchor and broke the link from filters.md, so use the em dash the rest of data-sources.md uses. The Lua module's API block listed every SMW source field except orderBy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SMW's parseOrderBy was a near-copy of Bucket's. Hoist it into SourceCompilerSupport, taking the allowed fields and how the error names them, with a native mixed type. SmwSourceCompiler now computes $hasSubjectColumn once instead of repeating the mainlabel test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Parse time is the only author-feedback point, but three mistakes got
past it:
- A numeric printout label ('Has population=2020') became an int array
key, so the strict field match rejected orderBy = { field = '2020' }.
- A non-string direction or a misspelled key such as `dir` silently
sorted ascending. Both now fail, for Bucket sources too.
- A printout labelled '_subject' passed orderBy validation but sorted by
page name, because '_subject' is the page column's key everywhere. The
label is now reserved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each backend special-cased "no sortModel means the spec's orderBy" in its own executeQuery, and the two copies differed: SMW treated the field as a colId, Bucket as a select string. AbstractBackendDataSource::getPage now substitutes the default once, and Bucket maps its select string to the colId through an orderByColId() override. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unless a wiki enables SMW_QSORT_UNCONDITIONAL, SMW sorts on a property by requiring a value for it, so pages without one drop out of the rows. The count query ran without sort keys and still counted them, so the total overshot and the Infinite Row Model padded the grid with blank rows. A default orderBy makes that the first view. countTotal() now receives the effective sort, and SMW's count query carries the same sort keys as the page query. The docs say which pages a property sort leaves out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The default sort lived only in the stored spec, so AG Grid showed no sort arrow and its header-click cycle started from "unsorted": the first click on an ascending default re-sent the same order. The compilers now set the column's colDef sort, which AG Grid shows and sends with its first fetch. The spec still covers a request whose sort the user cleared. The docs no longer compare orderBy with initialState.sortModel, a path AG Grid does not have (it is initialState.sort.sortModel). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Add order by support on a single field based on what bucket does.
This patch branch currently runs on star-citizen.wiki here: https://star-citizen.wiki/Comm-Link:%C3%9Cbersicht.
The data grid is generated and sorted by https://star-citizen.wiki/Modul:CommLinkList#L-72, where without the sort key, the list returns pages in ascending order, meaning oldest first.
This just sets the default order, client side can still override/change on what the sort runs on.
Code Disclosure: Generated by an LLM