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

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.ts — toRankTrackingCutoffTimestamp
  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.
@bensenescu

Copy link
Copy Markdown
Contributor

Hey,

Thanks for contributing!

For the next few months, I'm going to stop accepting external PRs. Reviewing and testing them has been slowing down progress against the roadmap.

Right now, the best way to contribute is through creating quality "Issues" which are easier for me to review and prioritize right now.

Here is our updated contributing guide: https://github.com/every-app/open-seo/blob/main/docs/CONTRIBUTING.md

Converting, this PR to an issue would be the best way to get it prioritized.

You can use the the /simple-issue-description skill described in the guide to convert the PR to an issue.

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.

2 participants