fix(memories): sort Month span by time within a day; test the real sorts #156

Merged
cameron merged 2 commits from fix/memories-month-sort into master 2026-09-30 03:07:40 +00:00
Owner

Summary

Month times jumped back and forth. The Month sort keyed on the display day only. The sort is stable, so a day's photos kept DB order, merged across libraries, and the displayed times jumped around (FileViewer renders server order as-is). Month now sorts like Week: full date, then timestamp, undated items last.

The Week sort test tested nothing. test_week_span_sorting_chronological_by_day sorted its own inline copy (day-of-month across years). 7d2a314 later made the real Week sort chronological (full date, then time) on purpose, but the test kept passing on its copy and disagreed with production.

  • The sort moves into sort_memories(&mut [(MemoryItem, NaiveDate)], MemoriesSpan); Month and Week share one arm, and the created comparison is written once.
  • Tests now call sort_memories for every span:
    • month_span_sorts_by_time_within_a_day: one day, two libraries, out of DB order, plus an undated item (fails on the old sort)
    • week_span_sorts_by_full_date_then_time: replaces the stale test; years group, time breaks same-day ties
    • day_span_sorts_by_timestamp_across_years: same calendar day across years, undated last

Note

Within a day the key is the true instant (created), not the displayed wall clock, same as Week/Day already were. They agree except when one day mixes photos from different time zones.

Verification

cargo fmt, cargo clippy --all-targets (0 warnings), cargo test --no-fail-fast: green apart from the known prefs::tests::put_prefs_* flake (passes in isolation; tracked separately).

🤖 Generated with Claude Code

## Summary **Month times jumped back and forth.** The Month sort keyed on the display day only. The sort is stable, so a day's photos kept DB order, merged across libraries, and the displayed times jumped around (FileViewer renders server order as-is). Month now sorts like Week: full date, then timestamp, undated items last. **The Week sort test tested nothing.** `test_week_span_sorting_chronological_by_day` sorted its own inline copy (day-of-month across years). 7d2a314 later made the real Week sort chronological (full date, then time) on purpose, but the test kept passing on its copy and disagreed with production. - The sort moves into `sort_memories(&mut [(MemoryItem, NaiveDate)], MemoriesSpan)`; Month and Week share one arm, and the `created` comparison is written once. - Tests now call `sort_memories` for every span: - `month_span_sorts_by_time_within_a_day`: one day, two libraries, out of DB order, plus an undated item (fails on the old sort) - `week_span_sorts_by_full_date_then_time`: replaces the stale test; years group, time breaks same-day ties - `day_span_sorts_by_timestamp_across_years`: same calendar day across years, undated last ## Note Within a day the key is the true instant (`created`), not the displayed wall clock, same as Week/Day already were. They agree except when one day mixes photos from different time zones. ## Verification `cargo fmt`, `cargo clippy --all-targets` (0 warnings), `cargo test --no-fail-fast`: green apart from the known `prefs::tests::put_prefs_*` flake (passes in isolation; tracked separately). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
cameron added 2 commits 2026-09-30 03:05:32 +00:00
The Month sort keyed on the display day only. The sort is stable, so a
day's photos kept DB order, merged across libraries, and their times
jumped back and forth. Month now sorts like Week: full date, then
timestamp (undated items last).

The sort moves into sort_memories so it can be tested directly; the new
test covers a multi-library, out-of-order day.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test_week_span_sorting_chronological_by_day sorted its own inline copy
(day-of-month across years), so it kept passing after 7d2a314 made the
real Week sort chronological (full date, then time), and it disagreed
with production. Replace it with a test that calls sort_memories, and
add one for Day, so all three spans are pinned against the real sort.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cameron merged commit 98527bb81f into master 2026-09-30 03:07:40 +00:00
cameron deleted branch fix/memories-month-sort 2026-09-30 03:07:40 +00:00
Sign in to join this conversation.