Skip to content

refactor(db): move the flag-validation maps into the view table - #259

Merged
ryanlewis merged 1 commit into
mainfrom
refactor/view-table-flag-maps
Sep 10, 2026
Merged

ryanlewis merged 1 commit into
mainfrom
refactor/view-table-flag-maps

Conversation

@ryanlewis

Copy link
Copy Markdown
Owner

Follows #240.

Why

#240 folded the four maps that shape a view's SQL into one viewSpec and deliberately left two out, because they gate flag validation at the CLI boundary rather than composing SQL. That left adding a view touching three places, and nothing tied the two maps' keys to the table, so a view could be added with its SQL in place and its flags forgotten.

What changed

dateFilterableViews and viewsWithoutProjectFilter are now supportsDateFilter and rejectsProjectFilter on the spec, set on the six views that need them. DateFilterableView and ProjectFilterableView read the table. Adding a view is now one entry and nothing else.

rejectsProjectFilter is the one flag stated in the negative, and that is what preserves the answer for a name that is not a view at all. The map it replaces listed the views that refuse the filter, so an unknown name came back filterable; a zero spec keeps it that way. supportsDateFilter is positive for the mirror-image reason: an unknown name was not date-filterable and still is not.

Verification

No SQL changes, and testdata/list_query_golden.txt is untouched — the two hundred view-and-filter combinations #240 pinned are unaffected, which is the point.

TestDateFilterableView and TestProjectFilterableView pin both answers against expectations spelled out in the test rather than derived from the table, so a spec that loses a flag fails rather than quietly redefining what is expected. The date test gained the repeating case it was missing, so between them the two now cover all ten views plus a name that is not one.

Checked against origin/main directly as well, rather than only through the tests: all three view flags — date-filterable, project-filterable and completable — give the same answer for every one of the ten views and for an unknown name.

Review

/code-review --fix at high effort found no correctness bugs and two low points, both taken. TestDateFilterableView pinned two hand-written lists of view names where its two siblings iterate the table, so a view added with the date flag set would have gone untested; it now walks views and keeps its explicit unknown-name case. The supportsDateFilter doc explained four of the five excluded views and omitted repeating.

I rewrote the second fix rather than taking it as offered. It filled the gap with a claim about what a template's startDate means — the recurrence rule's anchor rather than a scheduled date — and I could not verify that: the database this work was measured against holds no repeating items in either recurrence column, so there was nothing to check it against. The comments in this file carry measurements and get cited as authority, so the doc now gives the reason that follows from what the view is (it lists templates, not scheduled items, and the instances a template generates are ordinary rows in the dated views) and says plainly that the template startDate question was not measured.

Follows #240, which folded the four maps that shape a view's SQL into one `viewSpec` and left these two out as a separate question: they gate flag validation at the CLI boundary rather than composing SQL. Leaving them meant adding a view still touched three places, and nothing tied their keys to the table, so a view could be added with its SQL in place and its flags forgotten.

`dateFilterableViews` and `viewsWithoutProjectFilter` are now `supportsDateFilter` and `rejectsProjectFilter` on the spec. `DateFilterableView` and `ProjectFilterableView` read the table. Adding a view is one entry and nothing else.

`rejectsProjectFilter` is stated in the negative, which is what preserves the behaviour for a name that is not a view at all: the map it replaces listed the views that refuse the filter, so an unknown name was filterable, and a zero spec keeps it that way. `supportsDateFilter` is positive for the same reason in reverse — an unknown name was not date-filterable and still is not.

No SQL changes, and the golden file is untouched. `TestDateFilterableView` and `TestProjectFilterableView` pin both answers against expectations spelled out in the test rather than derived from the table; the former grew the `repeating` case, so between them the two now cover all ten views and an unknown name. Checked against origin/main directly as well: all three view flags give the same answer for every view and for a name that is not one.
@ryanlewis
ryanlewis merged commit 14ad1a8 into main Sep 10, 2026
8 checks passed
@ryanlewis
ryanlewis deleted the refactor/view-table-flag-maps branch September 10, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant