Skip to content

Merge feedback and points into one session_feedback table - #78

Merged
VidsterBroyo merged 1 commit into
mainfrom
feat/session-feedback
Nov 30, 2026
Merged

VidsterBroyo merged 1 commit into
mainfrom
feat/session-feedback

Conversation

@VidsterBroyo

@VidsterBroyo VidsterBroyo commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Notion ticket link

Ticket

Stack 1 of 3. This PR merges the tables. #79 unifies the read queries, and #80 adds attachment_id.

Implementation description

  • Why: in the design, the message and points share one Send button, one "Sent" stamp and one edit window. The code already kept feedback_log and session_points 1:1 by hand: same (session, student) key, written in one save, stamped with the same sent_at on send, with the author and timestamp columns stored twice. sendSessionReport also had to handle states like "feedback sent but points not" that only existed because there were two tables.
  • Schema: one session_feedback table: message (text, defaults to ''), the 10 point categories, given_by / updated_by, and a single sent_at. It's unique on (session, student). The migration drops the old tables without copying data, since the database is empty.
  • API:
    • SessionFeedback replaces Feedback, SessionPoints and SessionReport. The categories and total are nested under points, mirroring SessionPointsInput.
    • saveSessionFeedback / sendSessionFeedback replace saveSessionReport / sendSessionReport.
  • No behavior change to reads: every read query keeps its name and access rule, now backed by the new table. The next PR in the stack makes the read changes.
  • Service: feedbackService, sessionPointsService and sessionReportService become one sessionFeedbackService. Save and send each touch one row. Points accounting is unchanged: it still locks the student row and adjusts Student.points by the delta when sent feedback is edited.
  • Seed: the points fixtures are folded into the matching feedback rows (A/Today 7, A/Day 7 4, B/Today 3 draft), so A still ends at 11. The A/Day 7 pair had different authors before (coach for the feedback, admin for the points); the merged row keeps the coach.
  • assertManagesStudent (utils/auth.ts) is a new shared helper for the "caller manages this student" check that student and parent reads need. It throws FORBIDDEN. The feedback reads use it now, and the rewards queries can reuse it.
  • README and TODO are updated to match.

What should reviewers focus on?

  • The nested points object on SessionFeedback, instead of flat category fields.
  • Not run against a real database (Docker was down). Typecheck, lint and the GraphQL schema build pass. Please run prisma migrate deploy, a full seed, and the README's feedback, points and save/send checks.

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have run the appropriate linter(s)
  • I have requested a review from the TL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR

🤖 Generated with Claude Code

@VidsterBroyo
VidsterBroyo added this pull request to stack #81 November 30, 2026 02:02
@VidsterBroyo VidsterBroyo changed the title refactor: merge feedback_log and session_points into session_feedback Merge feedback and points into one session_feedback table Nov 30, 2026
@VidsterBroyo
VidsterBroyo marked this pull request as ready for review November 30, 2026 02:16
Feedback and points are saved, sent and edited together, so they now live in
one session_feedback row per student per session with a single sent_at. The
API returns SessionFeedback (points under `points`), and saveSessionFeedback /
sendSessionFeedback replace saveSessionReport / sendSessionReport. Existing
read queries keep their names and access rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@VidsterBroyo
VidsterBroyo merged commit 6fe5244 into main Nov 30, 2026
3 checks passed
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.

1 participant