Skip to content

Conversation

@luoling8192
Copy link
Collaborator

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @luoling8192, 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 delivers a significant new feature: the Annual Report. Users can now generate a comprehensive overview of their messaging activity for any given year, presented in an easy-to-understand format. This enhancement provides valuable insights into user engagement and communication patterns, making the application more useful for personal data analysis. The implementation spans across the UI, core backend logic, and database, ensuring a robust and integrated experience.

Highlights

  • New Feature: Annual Report: Introduced a new 'Annual Report' feature that allows users to generate and view a summary of their messaging activity for a selected year, including total messages, monthly activity, and top conversations.
  • User Interface: Added a new 'Annual Report' entry to the application sidebar and created a dedicated page (annual-report.vue) to display the report with interactive elements for year selection and report generation.
  • Database Schema: A new annual_reports table has been added to the database to store annual report data, including account ID, year, status, calculated statistics, and the processing plan.
  • Core Logic for Report Generation: Implemented core logic to fetch and process message data for a given year, calculate statistics such as total messages, monthly activity, and top chats, and manage the report generation progress and persistence.
  • Client-Side State Management: A new Pinia store (useAnnualReport) was created to manage the state of the annual report feature on the client-side, handling fetching status, progress updates, and displaying the generated statistics.
  • Localization Support: Added new localization keys for the annual report feature in both English (en.json) and Simplified Chinese (zh-CN.json) to support a multilingual user experience.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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
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 introduces a new Annual Report feature, which is a great addition. The implementation is solid, with good backend logic for generating the report, including resumability for long-running tasks. The frontend part is also well-structured. I've identified a few areas for improvement, mainly concerning internationalization on the new page, database schema robustness, and a couple of minor logic enhancements in the backend. Overall, great work on this significant new feature.

}))

if ((result instanceof Api.messages.MessagesSlice || result instanceof Api.messages.Messages) && 'count' in result) {
const count = result.count || result.messages.length
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The logic to determine the message count result.count || result.messages.length could be incorrect. When using messages.Search with limit: 1, result.count holds the total number of matching messages, while result.messages.length will be at most 1. Using result.messages.length as a fallback will lead to an incorrect (much lower) total count for the plan. You should rely solely on result.count.

Suggested change
const count = result.count || result.messages.length
const count = result.count ?? 0

class="w-full rounded-t-sm bg-primary/60 transition-all hover:bg-primary"
:style="{ height: `${(s.messageCount / (maxMonth?.messageCount || 1)) * 100}%` }"
>
<div class="absolute bottom-full mb-2 w-max rounded bg-black px-2 py-1 text-xs text-white hidden group-hover:block">
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The tooltip's background and text colors are hardcoded as bg-black and text-white. This will not adapt to theme changes (e.g., light/dark mode). It's better to use semantic color classes from your Tailwind theme to ensure consistency and proper display in all themes.

                  <div class="absolute bottom-full mb-2 w-max rounded bg-popover px-2 py-1 text-xs text-popover-foreground hidden group-hover:block">

{{ chat.chatName }}
</div>
<div class="text-xs text-muted-foreground">
ID: {{ chat.chatId }}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The prefix "ID: " is hardcoded, which is an internationalization issue. There's an existing translation key that seems perfect for this purpose.

                      {{ t('chatSelector.id', { id: chat.chatId }) }}

{{ chat.messageCount }}
</div>
<div class="text-xs text-muted-foreground">
messages
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The word "messages" is hardcoded. This should be internationalized for other languages. Please add a new key to your locale files (e.g., annualReport.messagesUnit) and use it here with t().

                    {{ t('annualReport.messagesUnit') }}

{{ t('annualReport.selectYear') }}
</h2>
<p class="mt-1">
Click generate to look back at your Telegram journey.
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This descriptive text is hardcoded. To support multiple languages, it should be moved to the locale files and accessed via t().

            {{ t('annualReport.generatePrompt') }}

stats.topChats = Object.entries(chatCounts)
.map(([id, data]) => ({ chatId: Number(id), chatName: data.name, messageCount: data.count }))
.sort((a, b) => b.messageCount - a.messageCount)
.slice(0, 20)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The number 20 is used here to limit the number of top chats. It's better to define this as a constant at the top of the file or in a shared constants file. This improves readability and makes it easier to change the value in the future.

Suggested change
.slice(0, 20)
.slice(0, 20) // TODO: Use a constant like TOP_CHATS_COUNT

Comment on lines +14 to +15
totalCount: integer().default(0),
processedCount: integer().default(0),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The totalCount and processedCount columns have a default value but are nullable. It's safer to make them non-nullable by adding .notNull() to prevent any unexpected null values and ensure data integrity at the database level. The existing code already seems to treat them as non-nullable.

Suggested change
totalCount: integer().default(0),
processedCount: integer().default(0),
totalCount: integer().notNull().default(0),
processedCount: integer().notNull().default(0),

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