Refactor and Finalize Session Tracking (Building on closed unmerged #74) #83
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR integrates and corrects the session tracking logic for the 10.0.x branch. It uses the service-layer approach originally proposed in PR #74, while addressing missing schema definitions and environment blockers currently on 10.0.x.
During testing, I identified issues that blocked development and limited the usefulness of the existing schema:
To resolve these, this PR:
duration_minutescolumn to the marking_sessions table, allowing session durations to be calculated and aggregated directly in the backend.Frontend impact
Persisting
duration_minutes enables direct aggregation via the API and removes the need for complex time-delta calculations in the Angular frontend. This change is intended to support(thoth-tech/doubtfire-web#402). By providing this data via the API, we avoid complex time-delta calculations in the Angular frontend, allowing 402 to be refactored to connect directly to this backend logic since the frontend contributions are yet to connect to exisitng backend.Type of change
How Has This Been Tested?
Test A: Migration Sequence
Executed bundle exec rails db:migrate:redo VERSION=20250922103033.
Verified:
marking_sessionstable is created successfullyduration_minutescolumn existsNo MySQL tablespace errors occur
Test B: Session Tracking Logic
Ran bundle exec ruby -I test test/services/session_tracker_test.rb.
Result: 2 runs, 13 assertions, 0 failures, 0 errors.
Confirmed:
15-minute "sticky" session window works
duration_minutesis correctly updated upon activity.Checklist: