Skip to content

fix(rank-tracking): use dialect-native timestamp cutoffs for comparisons - #172

Open
Ayush7614 wants to merge 1 commit into
every-app:mainfrom
Ayush7614:fix/rank-tracking-postgres-timestamp-cutoffs
Open

fix(rank-tracking): use dialect-native timestamp cutoffs for comparisons#172
Ayush7614 wants to merge 1 commit into
every-app:mainfrom
Ayush7614:fix/rank-tracking-postgres-timestamp-cutoffs

Conversation

@Ayush7614

@Ayush7614 Ayush7614 commented Jul 29, 2026

Copy link
Copy Markdown

Summary

  • Rank-tracking history and compare cutoffs always formatted timestamps like SQLite current_timestamp (YYYY-MM-DD HH:MM:SS).
  • Hosted Postgres stores checkedAt as ISO text (YYYY-MM-DDTHH:MM:SS.MSZ). Lexicographic gte/lte across those formats breaks same-day windows ( < T), so 1d/7d/30d deltas and history can be wrong.
  • Cutoffs now match the active database dialect.

How to review

  1. rankTrackingTimestamps.tstoRankTrackingCutoffTimestamp
  2. Call sites in snapshotQueries.ts and rankTrackingResults.ts
  3. Unit tests cover both D1 and Postgres formats

Test plan

  • pnpm exec vitest run src/server/features/rank-tracking/repositories/snapshotQueries.test.ts
  • On hosted Postgres, verify a 1d compare includes same-calendar-day snapshots written after the cutoff

Postgres stores ISO checkedAt text while cutoffs always used the SQLite
space-separated format, so 1d/7d/30d history windows compared wrong.
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