Skip to content

feat: Add weekly digest generation#8

Merged
devonjones merged 5 commits intomainfrom
feat/weekly-digest
Jan 15, 2026
Merged

feat: Add weekly digest generation#8
devonjones merged 5 commits intomainfrom
feat/weekly-digest

Conversation

@devonjones
Copy link
Copy Markdown
Owner

Summary

Implements automatic weekly digest generation at configurable time (default: Sunday 4pm UTC). Shows summary of past 7 days of captures, grouped by category with entry counts.

Changes

PostgresStorage (src/reflex/storage/postgres.py):

  • Add get_weekly_summary() method - queries entries from past 7 days, groups by category
  • Returns dict mapping category → list of (id, title, tags, captured_at)

ReflexBot (src/reflex/services/bot.py):

  • Add generate_weekly_digest() method
  • Schedule weekly digest job with CronTrigger (default: Sunday 4pm)
  • Add REFLEX_DIGEST_WEEKLY_DAY env var (default: "sunday")
  • Add REFLEX_DIGEST_WEEKLY_HOUR env var (default: 16)
  • Shows top 5 entries per category with "...and N more" if needed
  • No individual action buttons (unlike daily digest)

Design Decisions

  1. Aggregated view: Shows counts and top entries per category, not individual messages
  2. Pattern detection deferred: Ticket mentions "detect patterns (stuck projects, recurring themes)" - this is intentionally left for future iteration to keep MVP scope manageable
  3. No reactions: Weekly digest is informational only, not actionable
  4. Configurable schedule: Day-of-week and hour both configurable via env vars

Test Plan

  • Type checking passes (mypy)
  • Tests pass (pytest)
  • Deploy and verify weekly digest scheduled for Sunday 4pm
  • Manually trigger to test formatting
  • Verify daily digest still works

Future Enhancements

  • Pattern detection (stuck projects, recurring themes)
  • Comparison to previous week
  • Actionable insights ("3 admin items need attention")

Resolves

Closes cortex-vkv1

🤖 Generated with Claude Code

Implements automatic weekly digest generation showing summary of
past 7 days of captures, grouped by category with counts.

Changes:
- Add get_weekly_summary() to PostgresStorage (queries past 7 days, groups by category)
- Add generate_weekly_digest() method to ReflexBot
- Schedule weekly digest with APScheduler (default: Sunday 4pm UTC)
- Add REFLEX_DIGEST_WEEKLY_DAY and REFLEX_DIGEST_WEEKLY_HOUR env vars
- Show top 5 entries per category with count totals
- No pattern detection yet (deferred for future iteration)

The weekly digest provides a high-level overview without individual
action buttons, complementing the daily actionable digest.

Resolves: cortex-vkv1

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @devonjones, 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 introduces a new feature to automatically generate and send a weekly digest of captured entries. The digest provides users with a high-level summary of their activity over the last seven days, organized by category, and is designed to be informational rather than actionable. The scheduling of this digest is configurable through environment variables.

Highlights

  • Automatic Weekly Digest: Introduces automatic generation of a weekly digest, summarizing captured entries from the past seven days.
  • Configurable Schedule: The weekly digest schedule is configurable via REFLEX_DIGEST_WEEKLY_DAY and REFLEX_DIGEST_WEEKLY_HOUR environment variables, defaulting to Sunday at 4 PM UTC.
  • Categorized Summary: The digest groups entries by category, displays total entry counts, and highlights the top 5 most recent entries within each category.
  • Database Integration: A new get_weekly_summary method has been added to PostgresStorage to efficiently retrieve and categorize weekly data.
  • Bot Service Enhancement: The ReflexBot now includes a generate_weekly_digest method responsible for fetching the summary and formatting it for Discord, scheduled using CronTrigger.
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.

@devonjones
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown

@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 introduces a valuable weekly digest feature. The implementation is well-structured, with configurable scheduling and clear logic for generating the summary. My review focuses on improving maintainability and adhering to Python best practices. I've suggested using constants for magic numbers and configuration defaults, refactoring duplicated code into helper methods, and using more idiomatic Python for data manipulation. These changes will make the code cleaner and easier to manage in the long run.

Comment thread src/reflex/services/bot.py Outdated
Comment thread src/reflex/services/bot.py Outdated
Comment thread src/reflex/services/bot.py Outdated
Comment thread src/reflex/services/bot.py Outdated
Comment thread src/reflex/storage/postgres.py Outdated
- Add class constants: DAY_MAP, DEFAULT_WEEKLY_DIGEST_HOUR, WEEKLY_DIGEST_MAX_ENTRIES_PER_CATEGORY
- Extract title truncation logic into _truncate_title() helper method
- Use defaultdict(list) in postgres.py for cleaner grouping logic

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

Co-Authored-By: Claude <noreply@anthropic.com>
@devonjones
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown

@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 introduces a weekly digest generation feature, which is a great addition. The implementation is solid, with configurable scheduling via environment variables and a new storage method to fetch weekly data. My review includes a few suggestions to improve maintainability and consistency, such as using constants for default schedule values, avoiding code duplication by extracting helper methods, and using collections.defaultdict for more concise code. I also noticed a minor inconsistency in channel type handling between the daily and weekly digests.

Comment thread src/reflex/services/bot.py
Comment thread src/reflex/services/bot.py
Comment thread src/reflex/services/bot.py
Comment thread src/reflex/storage/postgres.py
Match the behavior of daily digest by allowing discord.Thread in addition to discord.TextChannel

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

Co-Authored-By: Claude <noreply@anthropic.com>
@devonjones
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown

@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 introduces a weekly digest generation feature, which is a valuable addition. The implementation is solid, with configurable scheduling and clear separation of concerns between the bot service and storage layer. I've included a few suggestions to improve code maintainability and database query efficiency. Overall, great work on this feature.

Comment thread src/reflex/services/bot.py
Comment thread src/reflex/services/bot.py Outdated
Comment thread src/reflex/storage/postgres.py
Copy link
Copy Markdown

@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 introduces a valuable weekly digest feature. The implementation is well-structured, adding scheduling and generation logic to ReflexBot and a corresponding data retrieval method in PostgresStorage. My review focuses on improving code quality and maintainability by addressing some code duplication, suggesting better placement for constants, and clarifying the handling of unused variables. These changes will help keep the codebase clean and easy to manage as it grows.

Comment thread src/reflex/services/bot.py
Comment thread src/reflex/services/bot.py Outdated
Comment thread src/reflex/services/bot.py Outdated
Replace unused variables (entry_id, tags, captured_at) with underscore for clarity

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

Co-Authored-By: Claude <noreply@anthropic.com>
@devonjones
Copy link
Copy Markdown
Owner Author

/gemini review

Extract day names array to DAY_NAMES class constant for better organization

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

Co-Authored-By: Claude <noreply@anthropic.com>
@devonjones
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown

@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 introduces a weekly digest feature, which is a great addition for summarizing weekly activity. The implementation correctly handles scheduling, configuration through environment variables, and fetching/formatting the digest content. The code is well-structured, and the new database query is efficient for its purpose. My review comments focus on improving maintainability by addressing a few instances of code duplication and suggesting ways to make constants more robust. These changes will help keep the codebase clean and easier to manage as it grows.

Comment thread src/reflex/services/bot.py
Comment thread src/reflex/services/bot.py
Comment thread src/reflex/services/bot.py
@devonjones
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown

@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 introduces a valuable feature for generating weekly digests. The implementation is well-executed, featuring configurable scheduling through environment variables and a new database query for weekly data aggregation. The code is generally well-structured, and the refactoring to extract title truncation logic is a good improvement. I have provided a few suggestions to further enhance maintainability by reducing code duplication and replacing hardcoded values with constants. Addressing these points will make the codebase more robust and easier to manage.

Comment thread src/reflex/services/bot.py
Comment thread src/reflex/services/bot.py
Comment thread src/reflex/services/bot.py
Copy link
Copy Markdown

@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 introduces a new weekly digest generation feature, which is a valuable addition. The implementation is clean, well-structured, and includes appropriate error handling for environment variable parsing. The refactoring of the title truncation logic into a dedicated helper method (_truncate_title) improves code maintainability. The scheduling of the weekly digest using CronTrigger is correctly set up, and the get_weekly_summary method in PostgresStorage efficiently retrieves and groups data. Overall, the changes are well-executed and align with good coding practices.

@devonjones devonjones merged commit 9745018 into main Jan 15, 2026
2 checks passed
@devonjones devonjones deleted the feat/weekly-digest branch January 15, 2026 17:29
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