Skip to content

feat(dashboard): add time period filter to all charts#1129

Merged
looplj merged 9 commits intolooplj:release/v0.9.xfrom
djdembeck:feature/dashboard-time-period-selectors
Mar 23, 2026
Merged

feat(dashboard): add time period filter to all charts#1129
looplj merged 9 commits intolooplj:release/v0.9.xfrom
djdembeck:feature/dashboard-time-period-selectors

Conversation

@djdembeck
Copy link
Copy Markdown
Contributor

@djdembeck djdembeck commented Mar 22, 2026

Summary

Adds a shared TimePeriodSelector component that enables consistent time period filtering across all dashboard charts. Users can now filter dashboard data by All Time, Month, Week, or Day.

Purpose

Before this change, dashboard charts displayed static data without any time-based filtering capability. This feature allows users to:

  • View request, token, cost, and performance data for specific time periods
  • Quickly switch between different time views (allTime, month, week, day)
  • Get consistent filtering across all dashboard widgets

Changes

New Component

  • Created TimePeriodSelector in frontend/src/components/time-period-selector.tsx
  • Reusable component with generic type support for flexibility
  • Uses i18n for internationalization support

Dashboard Integration

  • Integrated selector into:
    • Requests by Channel/Model/APIKey charts
    • Tokens by Channel/Model/APIKey charts
    • Cost by Channel/Model/APIKey charts
    • Fastest Performers cards (model/channel throughput)

Refactoring

  • Removed redundant condition in getDefaultPeriods function
  • Fixed type duplication by moving FastestTimeWindow to shared location

Testing

  • Verified all time period options (allTime, month, week, day) work correctly
  • Confirmed backend GraphQL accepts the correct time window values
  • TypeScript diagnostics pass with no errors

djdembeck and others added 8 commits March 19, 2026 15:41
Add optional timeWindow parameter to all 9 analytics queries:
- requestStatsByChannel, requestStatsByModel, requestStatsByAPIKey
- tokenStatsByChannel, tokenStatsByModel, tokenStatsByAPIKey
- costStatsByChannel, costStatsByModel, costStatsByAPIKey

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: Sisyphus <[email protected]>
Add time window filtering to all 9 analytics resolvers:
- RequestStatsByChannel, RequestStatsByModel, RequestStatsByAPIKey
- TokenStatsByChannel, TokenStatsByModel, TokenStatsByAPIKey
- CostStatsByChannel, CostStatsByModel, CostStatsByAPIKey

Supports day/week/month/allTime values. Skip filter when timeWindow
is nil, empty, or allTime.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: Sisyphus <[email protected]>
Regenerate generated.go with timeWindow parameter support.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: Sisyphus <[email protected]>
- Add TimePeriod type (day/week/month/allTime)
- Update all 9 analytics hooks to accept timeWindow parameter
- Include timeWindow in query keys for proper caching
- Update GraphQL queries to pass timeWindow variable

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: Sisyphus <[email protected]>
Add Tabs UI to all 6 analytics charts for time period selection:
- requests-by-channel-chart, requests-by-model-chart, requests-by-api-key-chart
- tokens-by-channel-chart, tokens-by-model-chart, tokens-by-api-key-chart

Features:
- 4 options: allTime (default), month, week, day
- Time period passed to data hooks
- Fix TypeScript error (remove invalid isAnimationActive from BarChart)

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)
Co-authored-by: Sisyphus <[email protected]>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the dashboard's time period selection mechanism by introducing a reusable component and integrating dynamic time window filtering into the backend GraphQL queries. These changes streamline the frontend UI, improve data fetching efficiency, and provide a more robust and user-friendly experience for viewing dashboard statistics.

Highlights

  • Refactored Time Period Selection: Introduced a new TimePeriodSelector component to centralize time period selection logic and UI, replacing redundant inline implementations across various dashboard cards.
  • Dynamic Dashboard Data Filtering: Implemented timeWindow arguments in GraphQL queries and their corresponding Go resolvers, enabling dynamic filtering of dashboard statistics (requests, tokens, costs) by 'day', 'week', 'month', or 'allTime'.
  • Improved Error Handling and Loading States: Enhanced the display of error messages to include specific details and added loading indicators (Loader2) to dashboard charts for a better user experience during data fetching.
  • Code Organization and Type Management: Moved the FastestTimeWindow type to a more appropriate shared location (time-period-selector.tsx) to improve code organization and reusability.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@djdembeck djdembeck changed the title refactor: remove redundant condition and move FastestTimeWindow type feat: add time period selectors to dashboard charts Mar 22, 2026
@djdembeck djdembeck changed the title feat: add time period selectors to dashboard charts feat(dashboard): add time period filter to all charts Mar 22, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the dashboard components to support time period selection for various charts. A new TimePeriodSelector component is introduced, and backend resolvers are updated to filter data based on the selected time window. My review focuses on a bug in the new selector component and an opportunity to reduce code duplication in the backend resolvers.

}

export function TimePeriodSelector<T extends string>({ value, onChange, periods }: TimePeriodSelectorProps<T>) {
const effectivePeriods = periods ?? getDefaultPeriods(value);
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.

high

The use of getDefaultPeriods(value) here introduces a bug. The set of available time periods shouldn't change based on the currently selected value. For example, if a user selects 'day' from a list that includes 'allTime', the 'allTime' option will disappear on the next render, preventing them from switching back.

The TimePeriodSelector should use a fixed default set of periods if none are provided via props. Please remove the getDefaultPeriods function (lines 16-22) and simplify this line.

Suggested change
const effectivePeriods = periods ?? getDefaultPeriods(value);
const effectivePeriods = periods ?? DEFAULT_PERIODS;

@looplj looplj merged commit 47604ee into looplj:release/v0.9.x Mar 23, 2026
2 checks passed
@djdembeck djdembeck deleted the feature/dashboard-time-period-selectors branch April 3, 2026 03:58
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