Skip to content

fix(api): restore AND in overview session COUNT SQL - #490

Merged
unjica merged 1 commit into
developfrom
fix/overview-session-count-sql-and
Jul 17, 2026
Merged

unjica merged 1 commit into
developfrom
fix/overview-session-count-sql-and

Conversation

@unjica

@unjica unjica commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: When GET /api/overview filters by environment and/or release, session COUNT SQL spliced upper-bound started_at / created_at clauses after the lower bound without a leading AND, producing invalid SQL like ... >= $n s."started_at" < ... (Postgres 42601 near "s"). Seen in production Sentry on overview.
  • Fix: overviewEnvironmentSessionCountUpperClauses now emits AND … on those upper bounds; SQL builder extracted for regression tests covering inclusive and exclusive compare windows.

Test plan

  • Unit tests in overview-stats.test.ts (15/15 locally) — assert AND before upper bounds and reject the glued >= s."started_at" shape
  • CI green (build, Bugbot / maintainer-review as applicable)
  • Smoke: overview with an environment (or release) filter for current + compare window loads without API 500 / Prisma raw query errors

Made with Cursor

Environment/release session counts omitted AND before upper-bound
started_at/created_at clauses, causing Postgres 42601 on GET /api/overview
(Sentry production).

Co-authored-by: Cursor <[email protected]>
@unjica

unjica commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator Author

Hotfix for production Sentry on GET /api/overview: missing AND before session/event upper-bound time clauses when env/release filters are set. Unit coverage added; leave open for CI before merge (do not disrupt release/v1.13.0 unless cherry-pick is needed later).

@unjica
unjica merged commit e077b99 into develop Jul 17, 2026
5 of 6 checks passed
@unjica
unjica deleted the fix/overview-session-count-sql-and branch July 17, 2026 01:00
@unjica unjica mentioned this pull request Jul 17, 2026
2 tasks
@unjica unjica added this to the v1.13.x — Dashboard UX milestone Jul 17, 2026
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