fix(search): restore start-date priority in comp_start_date (sc-46790) - #3673
Merged
yitzhakc merged 2 commits intoSep 2, 2026
Merged
Conversation
Split the nested getattr/or chain into explicit start/end lookups so the None-fallback priority (start, then end, then 3000) is unambiguous.
📊 Code Quality Score: 4/100
Was this score accurate? 👍 Yes · 👎 No Scored by GitVelocity · How are scores calculated? |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression in how text-index documents derive comp_date for chronological sorting by restoring “start year first” semantics and ensuring year 0 is treated as a valid year (not as “missing”).
Changes:
- Replaces truthiness-based fallback logic with explicit
is not Nonechecks when derivingcomp_date. - Restores priority order to prefer
TimePeriod.startoverTimePeriod.end, defaulting to3000only when both areNone.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+1220
to
+1222
| start = getattr(tp, 'start', None) | ||
| end = getattr(tp, 'end', None) | ||
| comp_start_date = int(start if start is not None else (end if end is not None else 3000)) |
Comment on lines
+1219
to
+1222
| tp = cls.best_time_period | ||
| comp_start_date = int(getattr(tp, 'end', None) or getattr(tp, 'start', 3000)) # If there is no end/start date, use 3000 which make it appear at the end of the results | ||
| start = getattr(tp, 'start', None) | ||
| end = getattr(tp, 'end', None) | ||
| comp_start_date = int(start if start is not None else (end if end is not None else 3000)) |
make_book_index_document had the identical regression from PR #3095: end prioritized over start, and \`or\` treating a year of 0 as missing. Extract _comp_date_from_time_period() and use it in both the text and book index builders so the two can't drift again. Existing book docs need a reindex to pick up the corrected compDate.
yodem
approved these changes
Aug 30, 2026
YishaiGlasner
enabled auto-merge
August 30, 2026 12:58
yitzhakc
disabled auto-merge
September 2, 2026 11:05
Contributor
|
Force merge |
📊 Code Quality Score: 6/100
Was this score accurate? 👍 Yes · 👎 No Scored by GitVelocity · How are scores calculated? |
This was referenced Sep 6, 2026
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.
Summary
getattr(tp, 'end', None) or getattr(tp, 'start', 3000), which unintentionally flipped priority from start→end to end→start, and usedor— so a legitimate year of0(falsy) was treated as missing and replaced with3000.make_book_index_document(the Books entity index) had the identical regression, mirroring the same buggy expression. Extracted a shared_comp_date_from_time_period()helper and use it in both the text index (TextIndexer) and the book index builders so they can't drift out of sync again.start, fall back toend, default to3000(orNonefor the sparse book-index field) only when both are actuallyNone— via explicitis not Nonechecks rather than truthiness.Test plan
0are no longer pushed to the end of chronological resultscompDatevalues baked in under the old logic will need a reindex to pick up the fix