Skip to content

feat(competitors): add date range filter to Competitors page - #1241

Merged
gkhngyk merged 8 commits into
ansvisor:mainfrom
knockknock10:feature/competitors-date-range-892
Oct 20, 2026
Merged

gkhngyk merged 8 commits into
ansvisor:mainfrom
knockknock10:feature/competitors-date-range-892

Conversation

@knockknock10

Copy link
Copy Markdown
Contributor

Summary

  • Add the shared date-range filter to the Competitors page with 7d, 30d, 90d, all-time, and custom presets.
  • Keep 30d as the default, matching the existing behavior.
  • Use the shared getDateRange helper and always pass days (including days: {} for all-time) so benchmark queries continue using the daily rollups instead of scanning all raw rows.
  • Reload benchmark and per-model comparison data when the selected range changes, while showing an inline loading indicator and ignoring stale responses.
  • Update the supporting text to reflect whether scores cover the last 30 days, all tracked history, or a selected range.
  • Leave the head-to-head panel unchanged, as requested in the issue.

Related issue

Closes #892

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

Checklist

  • Branch follows the naming convention (feature/)
  • Commits use Conventional Commit style
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Formatting passed locally. Web lint, typecheck and build need confirmation from the GitHub Actions run.

Copilot AI balanced review requested due to automatic review settings October 20, 2026 04:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Moving getDateRange out of Insights keeps both pages on the same logic, and 30 days stays the default.

All time: I timed it on our largest brand. competitor_aggregates_daily with no day bounds takes 2.4 s, against 0.6 s for 30 days and 1.6 s for 90, so All time can stay.

One change before merge:

Custom with empty dates reads all time. Choosing Custom reloads at once with empty from/to, and getDateRange returns { dayFrom: undefined, dayTo: undefined }, which is the unbounded read. Meanwhile the caption says "Scores reflect the selected date range". A range with only a "to" date does the same. Don't fetch for Custom until both dates are set, and keep the current data meanwhile.

Smaller:

  • Keep the range in the URL, as Insights does (preset, from, to). The page already keeps ?competitor=.
  • getCompetitors refetches on every range change, though the list doesn't depend on the range.

@knockknock10

Copy link
Copy Markdown
Contributor Author

Maintainer follow-up addressed on the current branch.

  • Custom comparison queries wait until both from and to are set; incomplete or “to”-only ranges keep the current comparison rather than fetching all-time data.
  • preset, from, and to are restored from and persisted to the URL while preserving the existing competitor parameter.
  • Competitor-list loading is now separate from comparison loading, so date changes do not refetch the unrelated list.
  • The shared getDateRange helper is used by both Insights and Competitors, with tests for 7d/30d/90d, all-time, custom, and 24h semantics.

Latest CI run #2384 passed web format/lint/typecheck/tests, server lint/format/tests, and schema consistency.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. A custom range now waits for both dates, the range survives a reload through the URL, and Insights and Competitors share one window helper. Tested on top of main with #1239, #1240, #1242 and #1131: web 1,796 tests pass, and tsc, lint and Prettier are clean.

@gkhngyk
gkhngyk merged commit 9e6b4dc into ansvisor:main Oct 20, 2026
5 checks passed
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.

feat(competitors): add a date range filter to the Competitors page

3 participants