Repository navigation
week2: Wire StreakModal to live streak data; record completedDates on… - #251
Merged
Merged
Conversation
karthikeya1976
approved these changes
Oct 1, 2026
karthikeya1976
left a comment
Collaborator
There was a problem hiding this comment.
Verified against the real server routes and ran a real TypeScript compile — approving, with a few things worth flagging (none blocking):
Confirmed correct:
GET /streakandGET /streak/calendarfield/param names match exactly (currentStreak,days,?username=,?username=&month=YYYY-MM).- The
completedDateswrite inactivities.jsis idempotent (checksalreadyRecordedbefore pushing) and correctly scoped to UTC midnight — won't double-write if a student re-triggers the same activity twice in a day. npx tsc --noEmit: clean.- The
environments/environment→environmentsimport fix inNewStudentProfile.tsxis a real, valuable fix (same bug class PR #208 fixed across ~30 files — importing the raw dev module bypasses prod config) — just wasn't called out in the PR description, worth mentioning explicitly next time so reviewers don't have to notice it by accident.
Worth knowing, not blocking this PR:
routes/streak.js's streak calculation (pre-existing, not touched by this PR) counts calendar-adjacent and non-adjacent completed days the same way — two active days with a gap between them still incrementcurrentStreak. This PR correctly wires the frontend to the real endpoint; the endpoint's own math bug is separate, already-known follow-up work.- The existing
e2e/streak-modal-flow.spec.tsexpects.calendar-day.is-today/.is-completedclasses and a "Previous month" nav button — this implementation uses plain.completedwith no month navigation. That spec isn't wired into CI, so it won't block merge, but it will fail if anyone runs it manually as-is. Worth a quick follow-up to either add month nav or update the spec to match what's actually built. - No
StreakModalunit test exists despite the e2e spec's comment referencing one — pre-existing gap, not introduced here. - Minor: the all-activities-complete check (read-then-push) isn't atomic against two different activities completing in true parallel — worst case is a harmless duplicate date in a low-stakes array, not worth blocking on.
Approving — the core wiring is correct and verified against live routes.
🤖 Generated with Claude Code
… full daily completion
sruju333
force-pushed
the
activitystreak
branch
from
October 5, 2026 20:25
6006f98 to
91e3736
Compare
8 of 14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes the two Week 2 gaps:
Activities.completedDateswas permanently empty for every student because nothing ever wrote to it, andStreakModalshowed a hardcoded streak/date with a placeholder calendar image instead of real data. This PR writescompletedDateswhen a student finishes all daily activities, and wires the modal to the existing/streakand/streak/calendarendpoints.Type of Change
Key Changes
middlewareNode/src/routes/activities.js: In thePUT /:username/activityhandler, after marking an activity complete, check if all daily activities are now complete. If so, push today's date intocompletedDates(deduped, so it's not written twice in a day).StreakModal.tsx: FetchesGET /streakandGET /streak/calendaron mount. Replaces the hardcoded9-day streak and static6/9date with live values, and replaces the placeholder calendar PNG with a real grid of completed days.StreakModal.scss: Added.calendar-grid/.calendar-daystyles to replace the old placeholder image styling.NewStudentProfile.tsx: Passesusernameinto<StreakModal />(previously missing, needed for the new data fetches).Testing
Bugs Fixed (if applicable)
Activities.completedDateswas initialized but never written to, so streak/badge stats relying on it were always zero for every student.TODO (Follow-up Work)
GET /streak/calendaronly returns days with recorded events, not a full padded month — consider filling in empty days client-side if a full calendar grid (aligned to weekdays) is desired.Additional Notes
None.