Skip to content

refactor: add support for epoch seconds#2253

Merged
jo-elimu merged 3 commits intomainfrom
2252-prevent-duplicates-during-batch-processing-of-learning-events
Jun 12, 2025
Merged

refactor: add support for epoch seconds#2253
jo-elimu merged 3 commits intomainfrom
2252-prevent-duplicates-during-batch-processing-of-learning-events

Conversation

@jo-elimu
Copy link
Copy Markdown
Member

Issue Number

Purpose

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.

@jo-elimu jo-elimu self-assigned this Jun 12, 2025
@jo-elimu jo-elimu requested a review from a team as a code owner June 12, 2025 17:14
@jo-elimu jo-elimu removed the request for review from a team June 12, 2025 17:14
@jo-elimu jo-elimu linked an issue Jun 12, 2025 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 12, 2025

Codecov Report

Attention: Patch coverage is 30.00000% with 14 lines in your changes missing coverage. Please review.

Project coverage is 16.14%. Comparing base (48ac843) to head (cd9ffe6).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...limu/dao/jpa/LetterSoundAssessmentEventDaoJpa.java 0.00% 1 Missing ⚠️
.../elimu/dao/jpa/LetterSoundLearningEventDaoJpa.java 0.00% 1 Missing ⚠️
...va/ai/elimu/dao/jpa/NumberLearningEventDaoJpa.java 0.00% 1 Missing ⚠️
...ai/elimu/dao/jpa/StoryBookLearningEventDaoJpa.java 0.00% 1 Missing ⚠️
...va/ai/elimu/dao/jpa/WordAssessmentEventDaoJpa.java 0.00% 1 Missing ⚠️
...java/ai/elimu/dao/jpa/WordLearningEventDaoJpa.java 0.00% 1 Missing ⚠️
...i/elimu/util/csv/CsvAnalyticsExtractionHelper.java 83.33% 1 Missing ⚠️
...etterSoundAssessmentEventsCsvExportController.java 0.00% 1 Missing ⚠️
.../LetterSoundLearningEventsCsvExportController.java 0.00% 1 Missing ⚠️
...dents/NumberLearningEventsCsvExportController.java 0.00% 1 Missing ⚠️
... and 4 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2253      +/-   ##
============================================
- Coverage     16.27%   16.14%   -0.13%     
+ Complexity      429      426       -3     
============================================
  Files           251      251              
  Lines          7140     7140              
  Branches        811      811              
============================================
- Hits           1162     1153       -9     
- Misses         5925     5935      +10     
+ Partials         53       52       -1     

☔ 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
Copy Markdown
Contributor

coderabbitai bot commented Jun 12, 2025

Walkthrough

This change updates timestamp handling in CSV analytics extraction and related DAO logging. Timestamp values are now truncated to seconds (multiplied by 1,000) during extraction, and corresponding tests are adjusted. Logging statements in several DAO classes are updated for consistency and accuracy in timestamp and parameter formatting. CSV export controllers now output timestamps in seconds instead of milliseconds. The main artifact version was also incremented.

Changes

File(s) Change Summary
src/main/java/ai/elimu/dao/jpa/LetterSoundAssessmentEventDaoJpa.java
src/main/java/ai/elimu/dao/jpa/LetterSoundLearningEventDaoJpa.java
src/main/java/ai/elimu/dao/jpa/NumberLearningEventDaoJpa.java
src/main/java/ai/elimu/dao/jpa/StoryBookLearningEventDaoJpa.java
src/main/java/ai/elimu/dao/jpa/VideoLearningEventDaoJpa.java
src/main/java/ai/elimu/dao/jpa/WordAssessmentEventDaoJpa.java
src/main/java/ai/elimu/dao/jpa/WordLearningEventDaoJpa.java
Logging in the read method catch blocks updated: use timestamp.getTime() instead of getTimeInMillis(), and improved formatting of log messages by removing quotation marks around parameters.
src/main/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelper.java Timestamp extraction now truncates to first 10 characters, converts to long, then multiplies by 1,000 for millisecond precision across all event extraction methods.
src/test/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelperTest.java Test assertions for event timestamps updated to expect values rounded to the nearest second (multiples of 1000).
src/main/java/ai/elimu/web/analytics/students/LetterSoundAssessmentEventsCsvExportController.java
src/main/java/ai/elimu/web/analytics/students/LetterSoundLearningEventsCsvExportController.java
src/main/java/ai/elimu/web/analytics/students/NumberLearningEventsCsvExportController.java
src/main/java/ai/elimu/web/analytics/students/StoryBookLearningEventsCsvExportController.java
src/main/java/ai/elimu/web/analytics/students/VideoLearningEventsCsvExportController.java
src/main/java/ai/elimu/web/analytics/students/WordAssessmentEventsCsvExportController.java
src/main/java/ai/elimu/web/analytics/students/WordLearningEventsCsvExportController.java
CSV export controllers updated to convert timestamps from milliseconds to seconds by dividing by 1,000 before printing.
pom-dependency-tree.txt Main artifact version updated from 2.6.56-SNAPSHOT to 2.6.58-SNAPSHOT.

Sequence Diagram(s)

sequenceDiagram
    participant CSV as CsvAnalyticsExtractionHelper
    participant DAO as EventDaoJpa
    participant DB as Database

    CSV->>CSV: Parse CSV record
    CSV->>CSV: Extract timestamp string (first 10 chars)
    CSV->>CSV: Convert to long and multiply by 1,000 (ms)
    CSV->>DAO: Call read(...) with processed timestamp
    DAO->>DB: Query event with parameters
    alt Event found
        DB-->>DAO: Return event
    else NoResultException
        DAO->>DAO: Log with timestamp.getTime() and formatted params
        DAO-->>CSV: Return null
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Prevent duplicates during batch processing of learning events (#2252)
Add more test cases to the VideoLearningEventDaoJpaTest (#2252) No new test cases were added to VideoLearningEventDaoJpaTest in this PR.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Main artifact version update (pom-dependency-tree.txt) Version bump is not related to the objectives of duplicate prevention or test case additions.

Possibly related PRs

Suggested reviewers

  • AshishBagdane
  • nya-elimu
  • tomaszsmy

📜 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 59d11b6 and cd9ffe6.

📒 Files selected for processing (7)
  • src/main/java/ai/elimu/dao/jpa/LetterSoundAssessmentEventDaoJpa.java (1 hunks)
  • src/main/java/ai/elimu/dao/jpa/LetterSoundLearningEventDaoJpa.java (1 hunks)
  • src/main/java/ai/elimu/dao/jpa/NumberLearningEventDaoJpa.java (1 hunks)
  • src/main/java/ai/elimu/dao/jpa/StoryBookLearningEventDaoJpa.java (1 hunks)
  • src/main/java/ai/elimu/dao/jpa/VideoLearningEventDaoJpa.java (1 hunks)
  • src/main/java/ai/elimu/dao/jpa/WordAssessmentEventDaoJpa.java (1 hunks)
  • src/main/java/ai/elimu/dao/jpa/WordLearningEventDaoJpa.java (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/ai/elimu/dao/jpa/VideoLearningEventDaoJpa.java
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/main/java/ai/elimu/dao/jpa/WordAssessmentEventDaoJpa.java
  • src/main/java/ai/elimu/dao/jpa/WordLearningEventDaoJpa.java
  • src/main/java/ai/elimu/dao/jpa/StoryBookLearningEventDaoJpa.java
  • src/main/java/ai/elimu/dao/jpa/NumberLearningEventDaoJpa.java
  • src/main/java/ai/elimu/dao/jpa/LetterSoundLearningEventDaoJpa.java
  • src/main/java/ai/elimu/dao/jpa/LetterSoundAssessmentEventDaoJpa.java
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: test_rest
  • GitHub Check: build (windows-latest, 17)
  • GitHub Check: build (macos-latest, 21)
  • GitHub Check: build (macos-latest, 17)
  • GitHub Check: build (ubuntu-latest, 21)
  • GitHub Check: test_rest
  • GitHub Check: build (ubuntu-latest, 17)
  • GitHub Check: build (windows-latest, 21)
  • GitHub Check: test_rest
  • GitHub Check: test_rest
  • GitHub Check: test_rest
✨ 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
Copy Markdown
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

🔭 Outside diff range comments (1)
src/main/java/ai/elimu/dao/jpa/NumberLearningEventDaoJpa.java (1)

23-29: ⚠️ Potential issue

Parameter name typo breaks query binding

setParameter("androidIdevent", androidId) (line 24) does not match the named parameter :androidId declared in the JPQL. This causes an IllegalArgumentException at runtime when the query executes.

-                .setParameter("androidIdevent", androidId)
+                .setParameter("androidId", androidId)
🧹 Nitpick comments (2)
src/main/java/ai/elimu/dao/jpa/LetterSoundLearningEventDaoJpa.java (1)

28-29: Minor: consider logging epoch milliseconds for easier grepping

timestamp.getTime() returns a Date whose default toString() is locale-dependent. Using timestamp.getTimeInMillis() (or timestamp.getTime().getTime()) yields a single numeric value that is easier to grep across logs.
No change required, just a suggestion.

src/main/java/ai/elimu/dao/jpa/LetterSoundAssessmentEventDaoJpa.java (1)

28-29: Same logging note as above

See previous comment regarding timestamp.getTime() vs milliseconds.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a6f8a82 and 4c19c90.

📒 Files selected for processing (10)
  • pom-dependency-tree.txt (1 hunks)
  • src/main/java/ai/elimu/dao/jpa/LetterSoundAssessmentEventDaoJpa.java (1 hunks)
  • src/main/java/ai/elimu/dao/jpa/LetterSoundLearningEventDaoJpa.java (1 hunks)
  • src/main/java/ai/elimu/dao/jpa/NumberLearningEventDaoJpa.java (1 hunks)
  • src/main/java/ai/elimu/dao/jpa/StoryBookLearningEventDaoJpa.java (1 hunks)
  • src/main/java/ai/elimu/dao/jpa/VideoLearningEventDaoJpa.java (1 hunks)
  • src/main/java/ai/elimu/dao/jpa/WordAssessmentEventDaoJpa.java (1 hunks)
  • src/main/java/ai/elimu/dao/jpa/WordLearningEventDaoJpa.java (1 hunks)
  • src/main/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelper.java (6 hunks)
  • src/test/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelperTest.java (7 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/main/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelper.java (1)
Learnt from: jo-elimu
PR: elimu-ai/webapp#2237
File: src/main/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelper.java:287-288
Timestamp: 2025-06-09T06:52:22.910Z
Learning: VideoLearningEvents in CsvAnalyticsExtractionHelper never used the "time" column name and always use "timestamp", unlike other event types (LetterSoundLearningEvent, WordAssessmentEvent, WordLearningEvent, StoryBookLearningEvent) which need conditional logic to handle both "time" (for versions < 3.4.0) and "timestamp" (for versions >= 3.4.0) column names. This is because VideoLearningEvents were introduced after the schema change.
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: build (ubuntu-latest, 17)
  • GitHub Check: build (windows-latest, 21)
  • GitHub Check: build (macos-latest, 21)
  • GitHub Check: build (windows-latest, 17)
  • GitHub Check: build (macos-latest, 17)
  • GitHub Check: build (ubuntu-latest, 21)
  • GitHub Check: test_rest
  • GitHub Check: test_rest
  • GitHub Check: test_rest
  • GitHub Check: test_rest
  • GitHub Check: test_rest
  • GitHub Check: test_rest
🔇 Additional comments (5)
pom-dependency-tree.txt (1)

1-1: Version bump looks fine – remember to sync release artefacts

The move to 2.6.58-SNAPSHOT is straightforward. Make sure the CHANGELOG and any deployment scripts reference the same version to avoid mismatched artefacts during CI/CD.

src/main/java/ai/elimu/dao/jpa/WordAssessmentEventDaoJpa.java (1)

28-28: Verify timestamp logging format. The switch to timestamp.getTime() logs a Date object instead of numeric milliseconds. Confirm this meets the epoch-second support goal; if not, revert to timestamp.getTimeInMillis().

src/main/java/ai/elimu/dao/jpa/StoryBookLearningEventDaoJpa.java (1)

36-36: Verify and standardize timestamp logging. Logging timestamp.getTime() emits a Date string rather than epoch milliseconds. Ensure this aligns with epoch-second requirements; otherwise use timestamp.getTimeInMillis().

src/main/java/ai/elimu/dao/jpa/WordLearningEventDaoJpa.java (1)

28-28: Verify timestamp logging behavior. Using timestamp.getTime() produces a Date object string, not numeric milliseconds. Confirm this change supports epoch-second logging, or switch back to timestamp.getTimeInMillis().

src/test/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelperTest.java (1)

37-37: Confirm updated timestamp assertions. All tests now expect timestamps truncated to second precision (multiples of 1000), matching the revised CSV extraction logic. The asserted values look correct.

Also applies to: 57-57, 80-80, 102-102, 124-124, 146-146, 168-168

Comment on lines +127 to 130
long timestampInMillis = Long.valueOf(csvRecord.get(timestampColumnName).substring(0, 10)) * 1_000;
Calendar timestamp = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
timestamp.setTimeInMillis(timestampInMillis);
letterSoundLearningEvent.setTimestamp(timestamp);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Guard against short or malformed timestamp strings & remove duplication

Each extractor now does

long ts = Long.valueOf(csvRecord.get(col).substring(0, 10)) * 1_000;

Issues:

  1. If the field has < 10 characters (e.g. empty or corrupted) substring throws StringIndexOutOfBoundsException.
  2. The same parsing logic is duplicated six times.

Proposed refactor (utility method + bounds check):

+    private static Calendar toUtcCalendarFromEpochSeconds(String raw) {
+        if (raw == null || raw.length() < 10) {
+            throw new IllegalArgumentException("Invalid epoch string: " + raw);
+        }
+        long millis = Long.parseLong(raw.substring(0, 10)) * 1_000L;
+        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+        cal.setTimeInMillis(millis);
+        return cal;
+    }

Then replace every block with:

- long timestampInMillis = Long.valueOf(csvRecord.get(col).substring(0, 10)) * 1_000;
- Calendar timestamp = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- timestamp.setTimeInMillis(timestampInMillis);
+ Calendar timestamp = toUtcCalendarFromEpochSeconds(csvRecord.get(col));

This removes repetition and makes failures explicit.

Also applies to: 174-177, 240-243, 306-309, 369-372, 430-433

🤖 Prompt for AI Agents
In src/main/java/ai/elimu/util/csv/CsvAnalyticsExtractionHelper.java around
lines 127 to 130, the code extracts a timestamp substring without checking its
length, risking StringIndexOutOfBoundsException if the string is shorter than 10
characters, and this parsing logic is duplicated multiple times. To fix this,
create a utility method that safely checks the length of the timestamp string
before extracting the substring and converting it to milliseconds, throwing a
clear exception if invalid. Replace all occurrences of the direct substring
parsing with calls to this utility method to remove duplication and improve
error handling. Apply the same refactor to lines 174-177, 240-243, 306-309,
369-372, and 430-433.

Comment thread src/main/java/ai/elimu/dao/jpa/VideoLearningEventDaoJpa.java Outdated
Copy link
Copy Markdown
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: 0

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

64-67: Replace magic number with TimeUnit for self-documentation

The / 1_000 conversion is functionally correct, but the hard-coded literal obscures intent. Using TimeUnit.MILLISECONDS.toSeconds(...) expresses the time-unit conversion explicitly and avoids magic numbers.

-import java.io.StringWriter;
+import java.io.StringWriter;
+import java.util.concurrent.TimeUnit;
...
-          numberLearningEvent.getTimestamp().getTimeInMillis() / 1_000,
+          TimeUnit.MILLISECONDS.toSeconds(
+              numberLearningEvent.getTimestamp().getTimeInMillis()),
src/main/java/ai/elimu/web/analytics/students/WordLearningEventsCsvExportController.java (1)

63-66: Prefer TimeUnit helper for clarity and to avoid magic numbers

The intent—convert milliseconds to epoch‐seconds—is clear, but the magic constant 1_000 invites accidental misuse later. Consider using the JDK’s built-in helper for self-documentation:

-          wordLearningEvent.getTimestamp().getTimeInMillis() / 1_000,
+          TimeUnit.MILLISECONDS.toSeconds(wordLearningEvent.getTimestamp().getTimeInMillis()),

This makes the unit conversion explicit and removes the hard-coded divisor.

src/main/java/ai/elimu/web/analytics/students/LetterSoundLearningEventsCsvExportController.java (2)

63-66: Prefer TimeUnit for clearer millis→seconds conversion

Dividing by a magic constant (1_000) works but obscures intent and risks accidental integer-division errors if the operand types ever change. Using TimeUnit makes the unit transformation explicit and self-documenting:

+import java.util.concurrent.TimeUnit;
...
-          letterSoundLearningEvent.getTimestamp().getTimeInMillis() / 1_000,
+          TimeUnit.SECONDS.convert(
+              letterSoundLearningEvent.getTimestamp().getTimeInMillis(),
+              TimeUnit.MILLISECONDS),

60-62: Downgrade per-event log entries to DEBUG to avoid log flooding

log.info inside a potentially large loop can spam application logs and impact I/O performance in production. Consider:

-      log.info("letterSoundLearningEvent.getId(): " + letterSoundLearningEvent.getId());
+      log.debug("letterSoundLearningEvent.getId(): {}", letterSoundLearningEvent.getId());

Also leverage parameterized logging to avoid unnecessary string concatenation.

src/main/java/ai/elimu/web/analytics/students/StoryBookLearningEventsCsvExportController.java (2)

67-70: Prefer TimeUnit for clearer, self-documenting time conversion

Dividing by 1_000 works but hides intent and can invite copy-paste mistakes. Using TimeUnit.MILLISECONDS.toSeconds(...) communicates why the division occurs and eliminates the magic number.

+import java.util.concurrent.TimeUnit;
...
-          storyBookLearningEvent.getTimestamp().getTimeInMillis() / 1_000,
+          TimeUnit.MILLISECONDS.toSeconds(storyBookLearningEvent.getTimestamp().getTimeInMillis()),

38-46: Use parameterized SLF4J instead of string concatenation

log.info("student.getAndroidId(): " + student.getAndroidId()); eagerly concatenates even when the log level is disabled and clutters code. Adopt placeholders:

-log.info("student.getAndroidId(): " + student.getAndroidId());
+log.info("student.getAndroidId(): {}", student.getAndroidId());

Apply similarly to other log statements in this controller.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4c19c90 and 59d11b6.

📒 Files selected for processing (7)
  • src/main/java/ai/elimu/web/analytics/students/LetterSoundAssessmentEventsCsvExportController.java (1 hunks)
  • src/main/java/ai/elimu/web/analytics/students/LetterSoundLearningEventsCsvExportController.java (1 hunks)
  • src/main/java/ai/elimu/web/analytics/students/NumberLearningEventsCsvExportController.java (1 hunks)
  • src/main/java/ai/elimu/web/analytics/students/StoryBookLearningEventsCsvExportController.java (1 hunks)
  • src/main/java/ai/elimu/web/analytics/students/VideoLearningEventsCsvExportController.java (1 hunks)
  • src/main/java/ai/elimu/web/analytics/students/WordAssessmentEventsCsvExportController.java (1 hunks)
  • src/main/java/ai/elimu/web/analytics/students/WordLearningEventsCsvExportController.java (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • src/main/java/ai/elimu/web/analytics/students/LetterSoundAssessmentEventsCsvExportController.java
  • src/main/java/ai/elimu/web/analytics/students/WordAssessmentEventsCsvExportController.java
  • src/main/java/ai/elimu/web/analytics/students/VideoLearningEventsCsvExportController.java
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test_rest
  • GitHub Check: build (ubuntu-latest, 17)
🔇 Additional comments (3)
src/main/java/ai/elimu/web/analytics/students/WordLearningEventsCsvExportController.java (2)

45-54: Header label no longer reflects the new unit

The header still reads "timestamp", which previously implied milliseconds. Now that the value is epoch seconds, downstream consumers might misinterpret it or double-convert. Recommend renaming to something explicit, e.g. "timestamp_seconds", and updating any documentation/import code accordingly.


60-68: Potential collision with sub-second events

Several learning events can legitimately share the same second. By truncating to seconds you lose ordering granularity and may generate duplicate timestamps. Verify that all downstream analytics tolerate this reduced precision (e.g. deduplication, sorting). If not, consider keeping milliseconds or appending a sequence column.

src/main/java/ai/elimu/web/analytics/students/StoryBookLearningEventsCsvExportController.java (1)

49-58: CSV header now misrepresents the unit

The field timestamp used to be milliseconds; it’s now seconds. Down-stream parsers or BI dashboards relying on the old unit will silently mis-interpret the value.

Options:

  1. Rename the column (e.g., timestamp_seconds) in the header for explicitness.
  2. Keep the name but bump a CSV schema/version and document the change.

Either way, ensure all consumers are updated before merging.

@jo-elimu jo-elimu merged commit 2d39db3 into main Jun 12, 2025
18 of 20 checks passed
@jo-elimu jo-elimu deleted the 2252-prevent-duplicates-during-batch-processing-of-learning-events branch June 12, 2025 17:31
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.

Prevent duplicates during batch processing of learning events

1 participant