Skip to content

GH-167 Improve review system.#167

Merged
vLuckyyy merged 5 commits intomasterfrom
improve-review-system
Jun 8, 2025
Merged

GH-167 Improve review system.#167
vLuckyyy merged 5 commits intomasterfrom
improve-review-system

Conversation

@vLuckyyy
Copy link
Member

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented May 24, 2025

Walkthrough

This update adds a new reminder service that regularly checks which GitHub reviewers need a nudge and sends them a message in the appropriate Discord thread. It introduces a new record and enum to track review details and statuses. The data model now stores extra info like review status, thread ID, and last reminder time. Several new methods and classes support these reminders and improve how mentions are managed. Some existing code was adjusted to use the new data and services, and unused imports were cleaned up. The reminder service starts with the app and stops gracefully on shutdown.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a980de3 and cb308b6.

📒 Files selected for processing (1)
  • src/main/java/com/eternalcode/discordapp/review/GitHubReviewReminderService.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/eternalcode/discordapp/review/GitHubReviewReminderService.java
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (6)
src/main/java/com/eternalcode/discordapp/review/GitHubReviewReminderService.java (5)

45-57: Add this. prefix to fix checkstyle issues.

The shutdown logic looks good, just need to add this. before scheduler references.

 public void stop() {
-    scheduler.shutdown();
+    this.scheduler.shutdown();
     try {
-        if (!scheduler.awaitTermination(60, TimeUnit.SECONDS)) {
-            scheduler.shutdownNow();
+        if (!this.scheduler.awaitTermination(60, TimeUnit.SECONDS)) {
+            this.scheduler.shutdownNow();
         }
     }
     catch (InterruptedException e) {
-        scheduler.shutdownNow();
+        this.scheduler.shutdownNow();
         Thread.currentThread().interrupt();
     }
     LOGGER.info("GitHub review reminder service stopped");
 }
🧰 Tools
🪛 GitHub Actions: Java CI with Gradle

[error] 46-46: Checkstyle: Reference to instance variable 'scheduler' needs "this.". (RequireThis)


[error] 48-48: Checkstyle: Reference to instance variable 'scheduler' needs "this.". (RequireThis)


[error] 49-49: Checkstyle: Reference to instance variable 'scheduler' needs "this.". (RequireThis)


[error] 53-53: Checkstyle: Reference to instance variable 'scheduler' needs "this.". (RequireThis)


59-73: Add this. prefix for checkstyle compliance.

The error handling looks good. Just need the prefix fixes.

 private void sendReminders() {
     try {
-        mentionRepository.getReviewersNeedingReminders(reminderInterval)
+        this.mentionRepository.getReviewersNeedingReminders(this.reminderInterval)
             .thenAccept(this::processReminders)
             .exceptionally(throwable -> {
                 Sentry.captureException(throwable);
                 LOGGER.log(Level.SEVERE, "Error sending reminders", throwable);
                 return null;
             });
     }
     catch (Exception exception) {
         Sentry.captureException(exception);
         LOGGER.log(Level.SEVERE, "Error scheduling reminders", exception);
     }
 }
🧰 Tools
🪛 GitHub Actions: Java CI with Gradle

[error] 61-61: Checkstyle: Reference to instance variable 'mentionRepository' needs "this.". (RequireThis)


[error] 61-61: Checkstyle: Reference to instance variable 'reminderInterval' needs "this.". (RequireThis)


75-79: Fix checkstyle issue with method call.

Add this. prefix to the method call.

 private void processReminders(List<GitHubReviewMentionRepository.ReviewerReminder> reminders) {
     for (GitHubReviewMentionRepository.ReviewerReminder reminder : reminders) {
-        sendReminder(reminder);
+        this.sendReminder(reminder);
     }
 }
🧰 Tools
🪛 GitHub Actions: Java CI with Gradle

[error] 77-77: Checkstyle: Method call to 'sendReminder' needs "this.". (RequireThis)


81-104: Fix checkstyle issues and consider tracking failed reminders.

Add this. prefix and maybe track when users or threads can't be found.

 private void sendReminder(GitHubReviewMentionRepository.ReviewerReminder reminder) {
     long userId = reminder.userId();
     String pullRequestUrl = reminder.pullRequestUrl();
     long threadId = reminder.threadId();

-    jda.retrieveUserById(userId).queue(
+    this.jda.retrieveUserById(userId).queue(
         user -> {
             if (user == null) {
                 LOGGER.warning("Could not find user with ID " + userId);
                 return;
             }

-            ThreadChannel thread = jda.getThreadChannelById(threadId);
+            ThreadChannel thread = this.jda.getThreadChannelById(threadId);
             if (thread == null) {
                 LOGGER.warning("Could not find thread with ID " + threadId);
                 return;
             }

-            sendReminderMessage(user, thread, pullRequestUrl);
+            this.sendReminderMessage(user, thread, pullRequestUrl);
         }, throwable -> {
             Sentry.captureException(throwable);
             LOGGER.log(Level.SEVERE, "Error retrieving user", throwable);
         });
 }
🧰 Tools
🪛 GitHub Actions: Java CI with Gradle

[error] 86-86: Checkstyle: Reference to instance variable 'jda' needs "this.". (RequireThis)


[error] 93-93: Checkstyle: Reference to instance variable 'jda' needs "this.". (RequireThis)


[error] 99-99: Checkstyle: Method call to 'sendReminderMessage' needs "this.". (RequireThis)


106-125: Add this. prefix for checkstyle.

The reminder logic looks good. Just need the prefix fix.

 thread.sendMessage(message).queue(
     success -> {
         GitHubPullRequest pullRequest = GitHubPullRequest.fromUrl(pullRequestUrl).orNull();
         if (pullRequest != null) {
-            mentionRepository.recordReminderSent(pullRequest, user.getIdLong());
+            this.mentionRepository.recordReminderSent(pullRequest, user.getIdLong());
         }
     },
     throwable -> {
         Sentry.captureException(throwable);
         LOGGER.log(Level.SEVERE, "Error sending reminder message", throwable);
     }
 );
🧰 Tools
🪛 GitHub Actions: Java CI with Gradle

[error] 117-117: Checkstyle: Reference to instance variable 'mentionRepository' needs "this.". (RequireThis)

src/main/java/com/eternalcode/discordapp/review/database/GitHubReviewMentionWrapper.java (1)

49-63: Factory method has good defaults but lacks validation.

The factory method correctly sets lastReminderSent to 0 for new mentions, but consider adding null checks for the input parameters.

 public static GitHubReviewMentionWrapper create(
     String pullRequest,
     long userId,
     Instant lastMention,
     GitHubReviewStatus reviewStatus,
     long threadId) {
+    if (pullRequest == null || lastMention == null || reviewStatus == null) {
+        throw new IllegalArgumentException("Required parameters cannot be null");
+    }
     return new GitHubReviewMentionWrapper(
         pullRequest,
         userId,
         lastMention.toEpochMilli(),
         reviewStatus.name(),
         threadId,
         0
     );
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce759d7 and 2bc7aa7.

📒 Files selected for processing (8)
  • src/main/java/com/eternalcode/discordapp/DiscordApp.java (4 hunks)
  • src/main/java/com/eternalcode/discordapp/review/GitHubReviewMention.java (1 hunks)
  • src/main/java/com/eternalcode/discordapp/review/GitHubReviewReminderService.java (1 hunks)
  • src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java (2 hunks)
  • src/main/java/com/eternalcode/discordapp/review/GitHubReviewStatus.java (1 hunks)
  • src/main/java/com/eternalcode/discordapp/review/database/GitHubReviewMentionRepository.java (1 hunks)
  • src/main/java/com/eternalcode/discordapp/review/database/GitHubReviewMentionRepositoryImpl.java (3 hunks)
  • src/main/java/com/eternalcode/discordapp/review/database/GitHubReviewMentionWrapper.java (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/main/java/com/eternalcode/discordapp/review/database/GitHubReviewMentionRepository.java (1)
src/main/java/com/eternalcode/discordapp/review/GitHubReviewMention.java (1)
  • GitHubReviewMention (3-49)
src/main/java/com/eternalcode/discordapp/review/database/GitHubReviewMentionRepositoryImpl.java (1)
src/main/java/com/eternalcode/discordapp/review/GitHubReviewMention.java (1)
  • GitHubReviewMention (3-49)
src/main/java/com/eternalcode/discordapp/review/database/GitHubReviewMentionWrapper.java (1)
src/main/java/com/eternalcode/discordapp/review/GitHubReviewMention.java (1)
  • GitHubReviewMention (3-49)
🪛 GitHub Actions: Java CI with Gradle
src/main/java/com/eternalcode/discordapp/review/GitHubReviewMention.java

[error] 27-27: Checkstyle: Reference to instance variable 'pullRequest' needs "this.". (RequireThis)


[error] 31-31: Checkstyle: Reference to instance variable 'userId' needs "this.". (RequireThis)


[error] 35-35: Checkstyle: Reference to instance variable 'lastMention' needs "this.". (RequireThis)


[error] 39-39: Checkstyle: Reference to instance variable 'reviewStatus' needs "this.". (RequireThis)


[error] 43-43: Checkstyle: Reference to instance variable 'threadId' needs "this.". (RequireThis)


[error] 47-47: Checkstyle: Reference to instance variable 'lastReminderSent' needs "this.". (RequireThis)

src/main/java/com/eternalcode/discordapp/review/GitHubReviewReminderService.java

[error] 41-41: Checkstyle: Reference to instance variable 'scheduler' needs "this.". (RequireThis)


[error] 46-46: Checkstyle: Reference to instance variable 'scheduler' needs "this.". (RequireThis)


[error] 48-48: Checkstyle: Reference to instance variable 'scheduler' needs "this.". (RequireThis)


[error] 49-49: Checkstyle: Reference to instance variable 'scheduler' needs "this.". (RequireThis)


[error] 53-53: Checkstyle: Reference to instance variable 'scheduler' needs "this.". (RequireThis)


[error] 61-61: Checkstyle: Reference to instance variable 'mentionRepository' needs "this.". (RequireThis)


[error] 61-61: Checkstyle: Reference to instance variable 'reminderInterval' needs "this.". (RequireThis)


[error] 77-77: Checkstyle: Method call to 'sendReminder' needs "this.". (RequireThis)


[error] 86-86: Checkstyle: Reference to instance variable 'jda' needs "this.". (RequireThis)


[error] 93-93: Checkstyle: Reference to instance variable 'jda' needs "this.". (RequireThis)


[error] 99-99: Checkstyle: Method call to 'sendReminderMessage' needs "this.". (RequireThis)


[error] 117-117: Checkstyle: Reference to instance variable 'mentionRepository' needs "this.". (RequireThis)

🔇 Additional comments (13)
src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java (2)

26-27: Formatting improvement looks good.

The multi-line format improves readability for the string constant.


145-145: Method signature update is correct.

Adding the forumId parameter aligns with the repository interface changes for tracking thread associations.

src/main/java/com/eternalcode/discordapp/review/GitHubReviewStatus.java (1)

3-31: Well-designed enum implementation.

The status values cover all relevant GitHub review states, and the fromString method provides flexible parsing with a sensible default fallback.

src/main/java/com/eternalcode/discordapp/DiscordApp.java (2)

73-73: Good approach using static field for shared repository.

This allows both GitHubReviewService and GitHubReviewReminderService to use the same repository instance.


186-191: Proper reminder service integration.

The service is correctly initialized and includes a shutdown hook for graceful cleanup.

src/main/java/com/eternalcode/discordapp/review/database/GitHubReviewMentionRepository.java (2)

16-23: Nice API design!

The new methods and ReviewerReminder record look clean and consistent with the async pattern.


12-12:

Details

✅ Verification successful

Check that all callers are updated with the new threadId parameter.

This is a breaking change to the interface. Make sure all implementations and callers pass the threadId.


🏁 Script executed:

#!/bin/bash
# Description: Find all calls to markReviewerAsMentioned to verify they're updated

# Search for method calls
rg -A 2 "markReviewerAsMentioned\(" --type java

Length of output: 415


All callers updated with the new threadId parameter

  • We found a single call in
    src/main/java/com/eternalcode/discordapp/review/GitHubReviewService.java
    and it now passes forumId as the threadId.
  • No other markReviewerAsMentioned( usages were detected.

Looks all set!

src/main/java/com/eternalcode/discordapp/review/database/GitHubReviewMentionWrapper.java (6)

3-4: Good addition of required imports.

The new imports for GitHubReviewStatus and GitHubReviewMention are correctly added to support the enhanced functionality.


9-9: Table name change looks intentional.

The table name change from "review_mentions" to "github_review_mentions" provides better clarity about the table's purpose.


21-28: New database fields are properly configured.

The three new fields are correctly annotated with @DatabaseField and use appropriate data types for their purposes.


34-46: Constructor properly handles new parameters.

The private constructor correctly initializes all new fields with the provided parameters.


89-95: Smart null handling for reminder timestamps.

The getter and setter methods handle the "never sent" state elegantly by using 0 as a sentinel value and converting to/from null.


97-106: Conversion method correctly maps all fields.

The toMention() method properly creates a GitHubReviewMention object using the raw stored values, which matches the expected constructor parameters.

Signed-off-by: Martin Sulikowski <vLuckyyy.biznes@gmail.com>
vLuckyyy added 3 commits June 8, 2025 23:16
Signed-off-by: Martin Sulikowski <vLuckyyy.biznes@gmail.com>
Signed-off-by: Martin Sulikowski <vLuckyyy.biznes@gmail.com>
Signed-off-by: Martin Sulikowski <vLuckyyy.biznes@gmail.com>
@vLuckyyy vLuckyyy changed the title Improve review system. GH-167 Improve review system. Jun 8, 2025
@vLuckyyy vLuckyyy merged commit e6d5bc9 into master Jun 8, 2025
3 checks passed
@vLuckyyy vLuckyyy deleted the improve-review-system branch June 8, 2025 21:48
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