Engagement heatmap API for unit-scoped task activity#88
Conversation
There was a problem hiding this comment.
This PR adds a well structured backend endpoint for the engagement heatmap, with clear logic in the service layer for computing the 84 day activity window and related metrics. The feature is easy to verify using the provided test command (bundle exec rails test test/api/projects_api_test.rb -n /engagement_heatmap/) and by calling GET /api/projects/:id/engagement_heatmap, which returns a consistent response including project_id, unit_id, range, days (84 entries), and summary. Test coverage is solid and the endpoint behaves as expected. The CI file reorganisation looks fine, though the change to run plagiarism checks daily is worth confirming. it looks good I am happy to approve.
|
@davidngash98 could you have a look at the unit tests |
Hey @BrianDangDev, I dug into the logs from all three runs the failure isn't actually in my tests, it's the Docker image build crashing before the test step ever runs. tlmgr (TeX Live's package manager) is failing while pulling LaTeX packages from the CTAN mirror inside the Dockerfile (tlmgr install catchfile csvsimple ... enumitem exits 1). My PR only touches the heatmap service, projects_api.rb, the test file, and config/environments/test.rb nothing in the Dockerfile or CI workflow so the same build would fail on any PR right now. The heatmap tests pass locally for me and for @millyamolo and @AjayPAnand . Since it's a separate infra issue, I'd rather not bundle a Dockerfile fix into this feature PR. I was suggesting if we can merge on the passing Ruby checks + manual verification let me know your thoughts. |
2c34163
into
thoth-tech:Feature/Peers-Progress



Summary
This adds a new backend API endpoint to support the Heatmap module for OnTrack. The endpoint provides an 84-day view of student task engagement activity, scoped strictly to a single project (enrolment). This will power the frontend heatmap visualisation without leaking data across units or projects.
Key Changes
New Service: app/services/engagement_heatmap_service.rb
New API Endpoint: GET /api/projects/:id/engagement_heatmap
Tests: Added comprehensive tests in test/api/projects_api_test.rb covering:
Test Environment Fix
How to Test
Run: bundle exec rails test test/api/projects_api_test.rb -n /engagement_heatmap/
Then call: GET /api/projects/:id/engagement_heatmap and verify the response includes:
project_id
unit_id
range
days (84 entries)
summary
Notes / Limitations