Skip to content

Conversation

@jo-elimu
Copy link
Member

@jo-elimu jo-elimu commented Jun 4, 2025

Issue Number

  • Resolves #

Purpose

Technical Details

Testing Instructions

Screenshots

image


Format Checks

Note

Files in PRs are automatically checked for format violations with mvn spotless:check.

If this PR contains files with format violations, run mvn spotless:apply to fix them.

@jo-elimu jo-elimu self-assigned this Jun 4, 2025
@jo-elimu jo-elimu requested a review from a team as a code owner June 4, 2025 07:27
@jo-elimu jo-elimu requested review from AshishBagdane, shiv810 and vuriaval and removed request for a team June 4, 2025 07:27
@codecov
Copy link

codecov bot commented Jun 4, 2025

Codecov Report

Attention: Patch coverage is 0% with 27 lines in your changes missing coverage. Please review.

Project coverage is 16.47%. Comparing base (1f86cca) to head (67d9c92).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...limu/web/analytics/students/StudentController.java 0.00% 27 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2220      +/-   ##
============================================
- Coverage     16.53%   16.47%   -0.07%     
  Complexity      419      419              
============================================
  Files           245      245              
  Lines          6754     6781      +27     
  Branches        780      785       +5     
============================================
  Hits           1117     1117              
- Misses         5586     5613      +27     
  Partials         51       51              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 4, 2025

Walkthrough

This change introduces analytics for student reading speed by calculating and displaying weekly averages of correct words per minute based on assessment events. The backend prepares and logs the data, while the frontend renders a new line chart in the student analytics view. Additionally, the project artifact version is incremented.

Changes

File(s) Change Summary
pom-dependency-tree.txt Updated main project artifact version from 2.6.32-SNAPSHOT to 2.6.34-SNAPSHOT.
src/main/java/ai/elimu/web/analytics/students/StudentController.java Added logic to compute weekly average reading speed (words per minute) and expose it to the view.
src/main/webapp/WEB-INF/jsp/analytics/students/id.jsp Added a Chart.js line chart to visualize weekly reading speed averages in the student analytics page.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant StudentController
    participant Model
    participant JSP (View)

    User->>StudentController: Request student analytics page
    StudentController->>StudentController: Fetch WordAssessmentEvents
    StudentController->>StudentController: Compute weekly reading speed averages
    StudentController->>Model: Add readingSpeedAvgList, weekList
    StudentController->>JSP (View): Render page with model data
    JSP (View)->>User: Display analytics page with reading speed chart
Loading

Possibly related PRs

Suggested reviewers

  • vrudas
  • eymaal
  • alexander-kuruvilla
✨ 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
Contributor

@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: 2

🧹 Nitpick comments (1)
src/main/java/ai/elimu/web/analytics/students/StudentController.java (1)

163-172: Consider removing debug logging statements.

The logging statements on lines 163, 165, 167, and 171 appear to be for debugging purposes. Consider removing them before production deployment to avoid log noise.

Apply this diff to remove debug logging:

-        log.info("wordsReadCount: " + wordsReadCount);
         Long timeSpentMsSum = timeSpentMsSumByWeekMap.getOrDefault(weekAsString, 0L);
-        log.info("timeSpentMsSum: " + timeSpentMsSum);
         Double timeSpentInMinutes = (double) timeSpentMsSum / 60_000.0;
-        log.info("timeSpentInMinutes: " + timeSpentInMinutes);
         Double wordsPerMinute = 0.00;
         if (timeSpentInMinutes > 0) {
           wordsPerMinute = wordsReadCount / timeSpentInMinutes;
-          log.info("wordsPerMinute: " + wordsPerMinute);
         }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c7f7c45 and 67d9c92.

📒 Files selected for processing (3)
  • pom-dependency-tree.txt (1 hunks)
  • src/main/java/ai/elimu/web/analytics/students/StudentController.java (1 hunks)
  • src/main/webapp/WEB-INF/jsp/analytics/students/id.jsp (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: test_ui
  • GitHub Check: build (macos-latest, 21)
  • GitHub Check: build (macos-latest, 17)
  • GitHub Check: test_rest
  • GitHub Check: build (windows-latest, 17)
  • GitHub Check: build (windows-latest, 21)
  • GitHub Check: build (ubuntu-latest, 21)
  • GitHub Check: build (ubuntu-latest, 17)
  • GitHub Check: test_rest
  • GitHub Check: test_rest
🔇 Additional comments (2)
pom-dependency-tree.txt (1)

1-1: LGTM: Standard version increment for new feature.

The version update from 2.6.32-SNAPSHOT to 2.6.34-SNAPSHOT appropriately reflects the addition of the reading speed analytics feature.

src/main/webapp/WEB-INF/jsp/analytics/students/id.jsp (1)

205-232: LGTM: Well-structured chart implementation.

The reading speed chart implementation follows the established patterns in the file with proper Chart.js configuration, consistent styling, and clear structure. The integration with the backend readingSpeedAvgList data is correct.

String eventWeek = simpleDateFormat.format(event.getTimestamp().getTime());
if (event.getMasteryScore() >= 0.5) {
eventCountByWeekMap.put(eventWeek, eventCountByWeekMap.getOrDefault(eventWeek, 0) + 1);
timeSpentMsSumByWeekMap.put(eventWeek, eventCountByWeekMap.getOrDefault(eventWeek, 0) + event.getTimeSpentMs());
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix the time sum calculation bug.

Line 156 incorrectly uses eventCountByWeekMap.getOrDefault(eventWeek, 0) instead of the time sum map.

Apply this diff to fix the bug:

-          timeSpentMsSumByWeekMap.put(eventWeek, eventCountByWeekMap.getOrDefault(eventWeek, 0) + event.getTimeSpentMs());
+          timeSpentMsSumByWeekMap.put(eventWeek, timeSpentMsSumByWeekMap.getOrDefault(eventWeek, 0L) + event.getTimeSpentMs());
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
timeSpentMsSumByWeekMap.put(eventWeek, eventCountByWeekMap.getOrDefault(eventWeek, 0) + event.getTimeSpentMs());
timeSpentMsSumByWeekMap.put(
eventWeek,
- eventCountByWeekMap.getOrDefault(eventWeek, 0) + event.getTimeSpentMs()
+ timeSpentMsSumByWeekMap.getOrDefault(eventWeek, 0L) + event.getTimeSpentMs()
);
🤖 Prompt for AI Agents
In src/main/java/ai/elimu/web/analytics/students/StudentController.java at line
156, the code incorrectly sums time spent by using eventCountByWeekMap instead
of timeSpentMsSumByWeekMap. Fix this by replacing
eventCountByWeekMap.getOrDefault(eventWeek, 0) with
timeSpentMsSumByWeekMap.getOrDefault(eventWeek, 0) to correctly accumulate the
total time spent per week.

log.info("wordsReadCount: " + wordsReadCount);
Long timeSpentMsSum = timeSpentMsSumByWeekMap.getOrDefault(weekAsString, 0L);
log.info("timeSpentMsSum: " + timeSpentMsSum);
Double timeSpentInMinutes = (double) (timeSpentMsSum / 1_000);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct the milliseconds to minutes conversion.

Line 166 incorrectly converts milliseconds to minutes by dividing by 1,000. The correct conversion should divide by 60,000 (1000ms × 60s = 60,000ms per minute).

Apply this diff to fix the conversion:

-        Double timeSpentInMinutes = (double) (timeSpentMsSum / 1_000);
+        Double timeSpentInMinutes = (double) timeSpentMsSum / 60_000.0;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Double timeSpentInMinutes = (double) (timeSpentMsSum / 1_000);
- Double timeSpentInMinutes = (double) (timeSpentMsSum / 1_000);
+ Double timeSpentInMinutes = (double) timeSpentMsSum / 60_000.0;
🤖 Prompt for AI Agents
In src/main/java/ai/elimu/web/analytics/students/StudentController.java at line
166, the conversion from milliseconds to minutes is incorrect because it divides
by 1,000 instead of 60,000. Fix this by changing the divisor from 1,000 to
60,000 to correctly convert milliseconds to minutes.

@jo-elimu jo-elimu merged commit c370900 into main Jun 4, 2025
19 of 20 checks passed
@jo-elimu jo-elimu deleted the reading-speed branch June 4, 2025 07:36
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