-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(analytics): add video learning events to dashboard #1923
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1923 +/- ##
============================================
- Coverage 15.97% 15.90% -0.08%
- Complexity 478 481 +3
============================================
Files 254 256 +2
Lines 7798 7866 +68
Branches 816 821 +5
============================================
+ Hits 1246 1251 +5
- Misses 6502 6565 +63
Partials 50 50 ☔ View full report in Codecov by Sentry. |
Caution Review failedThe pull request is closed. WalkthroughThe changes in this pull request involve the addition of a new "Videos" link in the navigation menu of the Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- src/main/webapp/WEB-INF/jsp/analytics/layout.jsp (1 hunks)
- src/main/webapp/WEB-INF/jsp/analytics/main.jsp (1 hunks)
🔇 Additional comments (2)
src/main/webapp/WEB-INF/jsp/analytics/main.jsp (1)
44-53
: LGTM! Card structure follows existing patterns.The new video learning events card maintains consistency with other cards in terms of layout, styling, and positioning.
src/main/webapp/WEB-INF/jsp/analytics/layout.jsp (1)
56-56
: LGTM! Navigation structure is well-implemented.The implementation:
- Follows the existing pattern for learning events
- Uses appropriate Material Icon
- Maintains consistent URL structure
- Properly placed in the learning events section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
src/main/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelper.java (3)
142-142
: Good use of UTC timezone, but needs consistent application.
Using UTC for timestamp storage is the correct approach. However, the getStoryBookLearningEventsFromCsvBackup
method still uses the system default timezone. Consider updating it for consistency.
Apply this change to the getStoryBookLearningEventsFromCsvBackup
method as well:
- Calendar timestamp = Calendar.getInstance();
+ Calendar timestamp = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
Line range hint 165-167
: Improve error handling for CSV parsing.
The current error handling only logs the exception and continues execution, which could lead to silent failures. Consider:
- Propagating the IOException to allow proper error handling by the caller
- Adding validation for the returned list size
Here's a suggested improvement:
- } catch (IOException ex) {
- logger.error(ex);
- }
+ } catch (IOException ex) {
+ logger.error("Failed to parse CSV file: " + csvFilePath, ex);
+ throw new RuntimeException("Failed to process video learning events", ex);
+ }
Line range hint 93-95
: Ensure consistent resource management.
The getStoryBookLearningEventsFromCsvBackup
method doesn't close the CSVParser, unlike the extractVideoLearningEvents
method. This could lead to resource leaks.
Add proper resource cleanup:
- } catch (IOException ex) {
- logger.error(ex);
- }
+ } catch (IOException ex) {
+ logger.error("Failed to parse CSV file: " + csvFilePath, ex);
+ throw new RuntimeException("Failed to process storybook learning events", ex);
+ } finally {
+ if (csvParser != null) {
+ try {
+ csvParser.close();
+ } catch (IOException e) {
+ logger.error("Failed to close CSV parser", e);
+ }
+ }
+ }
Alternatively, use try-with-resources for both methods:
try (Reader reader = Files.newBufferedReader(csvFilePath);
CSVParser csvParser = new CSVParser(reader, csvFormat)) {
// Existing parsing logic
}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- src/main/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelper.java (2 hunks)
🔇 Additional comments (1)
src/main/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelper.java (1)
142-144
: Verify timezone handling in the analytics dashboard.
The change to UTC timezone storage might affect how timestamps are displayed in the analytics dashboard.
Let's verify the timestamp handling in the related JSP files:
✅ Verification successful
Based on the gathered information, I can now provide the final response:
The timezone change to UTC storage is safe and won't affect analytics display.
The analytics views are using simple date formatting patterns ("yyyy-MM-dd" and "yyyy-MM-dd HH:mm:ss") without explicit timezone handling, which means they'll use the server's default timezone for display. The controllers use basic SimpleDateFormat
for aggregating monthly statistics, which also adapts to the server's timezone automatically. Since the timestamps are properly stored in UTC, they will be correctly converted to the server's timezone when displayed.
- JSP files use
<fmt:formatDate>
which automatically handles timezone conversion - Analytics controllers (
WordLearningEventListController
andStoryBookLearningEventListController
) use timezone-agnostic formatting - No explicit timezone conversions are needed in the display layer
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for timestamp formatting in analytics-related JSP files
fd -e jsp -x rg -l "timestamp|Calendar|Date|format" {} \;
# Search for any timezone-related configuration
fd . -e xml -e properties -e java -x rg -l "timezone|TimeZone" {} \;
Length of output: 2017
Script:
#!/bin/bash
# Let's check the timestamp handling in analytics JSP files
rg -A 5 "timestamp|Calendar|Date|format" ./src/main/webapp/WEB-INF/jsp/analytics/word-learning-event/list.jsp ./src/main/webapp/WEB-INF/jsp/analytics/storybook-learning-event/list.jsp ./src/main/webapp/WEB-INF/jsp/analytics/letter-learning-event/list.jsp
# Check for any timezone-specific formatting or display logic in Java files
ast-grep --pattern 'class $_ {
$$$
format($$$) {
$$$
}
$$$
}'
# Check for any date/time formatting utilities
rg -l "SimpleDateFormat|DateTimeFormatter|format.*time" --type java
Length of output: 5625
Script:
#!/bin/bash
# Let's check the timestamp handling in the analytics controllers
rg -A 5 "timestamp|Calendar|Date|format" src/main/java/ai/elimu/web/analytics/StoryBookLearningEventListController.java src/main/java/ai/elimu/web/analytics/WordLearningEventListController.java
# Check if there's any timezone conversion or handling in these controllers
rg "TimeZone|ZoneId|timezone" src/main/java/ai/elimu/web/analytics/
# Check for any global date/time formatting configuration
fd . -e xml -e properties -x rg "format.*date|timezone|TimeZone" {} \;
Length of output: 8022
Issue Number
VideoLearningEvent
#1894Purpose
Technical Details
Testing Instructions
Screenshots
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.