Repository navigation
fix: resolve natural language dates when converting filters to Bases - #2403
Closed
thaidmfinnick wants to merge 1 commit into
Closed
thaidmfinnick wants to merge 1 commit into
thaidmfinnick wants to merge 1 commit into
Conversation
Saved-view conversion copied natural language date values verbatim, so `due is today` became `note.due == "today"` (never matches) and `due is on or before today` became `note.due <= "today"` (a string comparison that matches every date, including future ones). Date comparisons against natural language values now emit Bases expressions relative to today(), compared by date part like FilterUtils. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
Closing: opened by mistake while investigating a v3 issue that's already fixed in v4. |
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.
Problem
BasesFilterConvertercopies natural language date values as plain strings:todaynote.due == "today"todaynote.due <= "today"The in-memory filter (
FilterUtils) resolves these values withresolveNaturalLanguageDate, but the Bases converter never does, so converted saved views behave differently from the original v3 views.Fix
Add
getNaturalLanguageDateOffsetDays()todateUtils. It returns the day offset for the same patternsresolveNaturalLanguageDatesupports (today,tomorrow,yesterday,next/last week,in N days/weeks,N days/weeks ago).In
convertOperator, when a date property (due,scheduled,completedDate,dateCreated,dateModified, or adateuser field) is compared to a natural language value, emit an expression relative totoday(). The comparison uses the date part, likeFilterUtilsand the default base templates do:The date stays relative, so the generated
.basefile is still correct on later days.Literal dates and non-date properties are unchanged.
Tests
tests/unit/services/BasesFilterConverter.naturalLanguageDates.test.ts: 13 of its cases fail before this change.npm run test:unitpasses, as do eslint and prettier on the changed files andtsc --noEmit.Video error and demo
Error
https://github.com/user-attachments/assets/6e1a1722-fa61-41e9-8d1e-4cc363777ee0