Skip to content

Add 90-day timespan option and change default to 30d#252

Open
rajivsinclair wants to merge 1 commit intotrending-uifrom
add-90d-timespan
Open

Add 90-day timespan option and change default to 30d#252
rajivsinclair wants to merge 1 commit intotrending-uifrom
add-90d-timespan

Conversation

@rajivsinclair
Copy link
Contributor

@rajivsinclair rajivsinclair commented Nov 26, 2025

Summary

This PR adds a 90-day (90d) timespan option to the Trending Topics feature and changes the default from "All" to "30d" for better performance.

Changes Made

1. src/hooks/useSnippetFilters.tsx (line 4)

Before: export type Timespan = '24h' | '7d' | '30d' | 'all'
After: export type Timespan = '24h' | '7d' | '30d' | '90d' | 'all'

  • Added '90d' to the TypeScript union type
  • This enables type-safe usage of 90d throughout the codebase

2. src/components/ui/trending-card.tsx (lines 37-43)

Before:

const TIMESPAN_OPTIONS = [
  { value: '24h', label: '24h' },
  { value: '7d', label: '7d' },
  { value: '30d', label: '30d' },
  { value: 'all', label: 'All' }
]

After:

const TIMESPAN_OPTIONS = [
  { value: '24h', label: '24h' },
  { value: '7d', label: '7d' },
  { value: '30d', label: '30d' },
  { value: '90d', label: '90d' },
  { value: 'all', label: 'All' }
]

3. src/components/ui/trending-card.tsx (line 89)

Before: const [timespan, setTimespan] = useState<Timespan>('all')
After: const [timespan, setTimespan] = useState<Timespan>('30d')

  • Changed default from 'all' to '30d' for faster initial load

Backend Support

The Supabase RPC functions get_trending_topics and get_topic_details already support '90d' via migrations:

  • 20251126072129_add_90d_support_to_get_trending_topics
  • 20251126072204_add_90d_support_to_get_topic_details

The 90d option uses:

  • 90-day interval
  • 9-day bucket size
  • 10 buckets for sparkline visualization

Implementation Analysis

Why this approach is optimal:

  1. Minimal changes: Only 3 lines changed across 2 files
  2. Type safety preserved: Added to existing union type, no type gymnastics
  3. Backward compatible: 'all' option is preserved for users who want full history
  4. Follows existing patterns: Implemented identically to 24h/7d/30d options
  5. No filtering logic touched: Topic filtering (handleTopicClick, setFilters) is completely unchanged

What was NOT changed (and why):

  • Topic filtering logic: The handleTopicClick and handleExitFocusMode functions remain identical
  • Filter state management: useSnippetFilters hook's setFilters function is unchanged
  • Query keys: React Query caching logic is unchanged
  • UI rendering: Component structure and styling unchanged

Risk Assessment

Low risk - These changes are purely additive:

  • Adding a new option to an existing array
  • Extending a TypeScript type union
  • Changing a default value

No breaking changes to:

  • API contracts
  • Data structures
  • Component interfaces
  • Filter behavior

Testing Checklist

  • 90d button appears in the timespan selector
  • 90d loads data correctly with proper sparkline
  • Default is now 30d on fresh page load
  • All other timespans (24h, 7d, 30d, All) still work
  • Focus Mode still works when clicking a topic
  • Topic filtering correctly filters snippets
  • Exit Focus Mode returns to Discovery Mode

Deployment Notes

For Fly.io deployment, remember to include build args:

flyctl deploy --app verdad-browser --build-arg VITE_SUPABASE_URL="..." --build-arg VITE_SUPABASE_ANON_KEY="..." ...

🤖 Generated with Claude Code


Important

Adds 90-day timespan option to Trending Topics and changes default to 30 days for better performance.

  • Behavior:
    • Adds '90d' to Timespan type in useSnippetFilters.tsx.
    • Updates TIMESPAN_OPTIONS in trending-card.tsx to include '90d'.
    • Changes default timespan from 'all' to '30d' in trending-card.tsx.
  • Backend Support:
    • Supabase RPC functions get_trending_topics and get_topic_details already support '90d'.
  • Implementation:
    • Minimal changes: 3 lines across 2 files.
    • Type safety preserved with TypeScript union type.
    • Backward compatible: 'all' option remains.
  • Risk Assessment:
    • Low risk: purely additive changes.
    • No breaking changes to API, data structures, or component interfaces.

This description was created by Ellipsis for 21df5d8. You can customize this summary. It will automatically update as commits are pushed.

- Add '90d' to Timespan type union in useSnippetFilters.tsx
- Add 90d option to TIMESPAN_OPTIONS array in trending-card.tsx
- Change default timespan from 'all' to '30d' for better initial load performance

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings November 26, 2025 19:26
@vercel
Copy link

vercel bot commented Nov 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
verdad-frontend Ready Ready Preview Comment Nov 26, 2025 7:26pm

@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-90d-timespan

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @rajivsinclair, 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 enhances the Trending Topics feature by introducing a new 90-day timespan option and optimizing the user experience by setting the default timespan to 30 days instead of "All". These changes are primarily additive, involving updates to type definitions and UI options, and are designed to improve performance without altering core filtering logic.

Highlights

  • New Timespan Option: Introduced a '90d' (90-day) timespan option for the Trending Topics feature, allowing users to view trends over a longer period.
  • Default Timespan Change: The default timespan for Trending Topics has been updated from 'all' to '30d' to enhance initial load performance.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

Copy link

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 21df5d8 in 1 minute and 31 seconds. Click for details.
  • Reviewed 34 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. src/components/ui/trending-card.tsx:89
  • Draft comment:
    Default state for timespan updated to '30d'. Note that useSnippetFilters still defaults to '7d' – consider syncing these defaults for a consistent behavior.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. src/hooks/useSnippetFilters.tsx:44
  • Draft comment:
    The fallback default for timespan remains '7d'. If the new default is intended to be '30d' everywhere, update this fallback accordingly.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_Ei9X7Vp23dA5TxqV

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link

@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 correctly adds a '90d' timespan option and changes the default timespan to '30d' for better performance, as described. The changes are straightforward and well-documented in the pull request description. I have one suggestion regarding maintainability: to centralize the definition of timespan options and the Timespan type to prevent them from becoming out of sync in the future. This would make the code more robust and easier to maintain.

{ value: '24h', label: '24h' },
{ value: '7d', label: '7d' },
{ value: '30d', label: '30d' },
{ value: '90d', label: '90d' },

Choose a reason for hiding this comment

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

medium

While adding this new option is correct, there's an opportunity to improve long-term maintainability. Currently, the Timespan type is defined in src/hooks/useSnippetFilters.tsx while the TIMESPAN_OPTIONS array is defined here. This separation means that adding or removing a timespan requires changes in two different files, which can be error-prone.

To create a single source of truth, you could define the TIMESPAN_OPTIONS array in useSnippetFilters.tsx and derive the Timespan type from it. For example:

// In src/hooks/useSnippetFilters.tsx
export const TIMESPAN_OPTIONS = [
  { value: '24h', label: '24h' },
  { value: '7d', label: '7d' },
  { value: '30d', label: '30d' },
  { value: '90d', label: '90d' },
  { value: 'all', label: 'All' }
] as const;

export type Timespan = (typeof TIMESPAN_OPTIONS)[number]['value'];

You could then export TIMESPAN_OPTIONS from useSnippetFilters.tsx and import it here. This would ensure the type and the options are always synchronized.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the Trending Topics feature by adding a 90-day timespan option and improving initial load performance by changing the default timespan from "All" to "30d". The changes are minimal, type-safe, and well-integrated with existing backend support.

Key changes:

  • Extended the Timespan type union to include '90d'
  • Added 90d option to the timespan selector UI
  • Changed default timespan from 'all' to '30d' for better performance

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/hooks/useSnippetFilters.tsx Extended Timespan type definition to include '90d' option
src/components/ui/trending-card.tsx Added 90d to timespan selector options and changed default state from 'all' to '30d'

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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