Feature: Generate alumni candidates during election handoff by graduation month #502

Open
opened 2026-04-28 07:15:12 +00:00 by jjalangtry · 0 comments
jjalangtry commented 2026-04-28 07:15:12 +00:00 (Migrated from github.com)

Problem

Auto-generated alumni review rows currently appear from profile/sign-in activity, not from the election handoff flow.

Current behavior:

  • next/lib/services/alumniCandidateService.ts creates an AlumniCandidate when hasTermPassed(graduationTerm, graduationYear) is true
  • maybeCreateAlumniCandidate() runs from next/lib/authOptions.ts on sign-in
  • maybeCreateAlumniCandidate() also runs from next/app/api/user/route.ts after profile updates

That means a pending alumni review can appear just because a user signs in or edits their profile after their graduation term has passed. The desired behavior is narrower: auto-generated alumni requests should appear only as part of the end-of-election / new-semester handoff when the graduating student is in the graduation month/year associated with that election cycle.

Example: if a student graduates in May 2026, then clicking the end-of-election / send-invites button for the May 2026 election cycle should generate their automatic alumni review row.

Proposed Solution

Move automatic alumni candidate generation into the post-election handoff flow.

Likely trigger point:

  • POST /api/elections/[id]/send-officer-invites, used by next/app/(main)/dashboard/new-semester/[electionId]/NewSemesterClient.tsx when SE Office clicks Send invites

If the product flow changes to combine certification, new-semester start, and invite dispatch into a single end-election action, put the alumni generation in that single orchestrator instead. The key requirement is that the generation happens from the election-cycle handoff button, not from normal sign-in/profile-update side effects.

Eligibility Rule

Create an auto alumni candidate only when both are true:

  1. The user has provided a graduation month and graduation year
  2. The graduation month/year matches the current election cycle's handoff month/year

Suggested election-cycle date source:

  • Prefer Election.votingCloseAt or Election.certifiedAt as the election-cycle reference date, and document the chosen source
  • Compare (graduationMonth, graduationYear) to that reference month/year

Important current-data note: the schema currently stores graduationTerm and graduationYear, not a precise graduation month. This issue should either add a graduationMonth field or explicitly define a reliable term-to-month mapping before implementing the month/year check.

Scope

In scope:

  • Stop creating automatic alumni candidates from sign-in
  • Stop creating automatic alumni candidates from ordinary profile updates
  • Add or derive a precise graduation month for the user profile
  • Add a batch generator that runs during election handoff / officer invite dispatch
  • Generate pending AlumniCandidate rows only for users whose graduation month/year matches the election-cycle reference month/year
  • Avoid duplicate candidates for users who already have an Alumni record or an existing candidate
  • Return a count of generated alumni candidates from the handoff endpoint so the UI can toast/report it
  • Update the handoff UI copy to mention alumni candidates generated, if any

Out of scope:

  • Automatically approving alumni candidates
  • Sending alumni-specific emails unless added as a separate follow-up
  • Changing the manual public alumni request form

Acceptance Criteria

  • Signing in no longer creates an automatic alumni candidate
  • Editing a profile no longer creates an automatic alumni candidate just because the graduation date has passed
  • Clicking the election handoff / send-invites button creates pending alumni candidates for users graduating in the election-cycle month/year
  • A user graduating in May 2026 is generated during the May 2026 election handoff, not before and not for other election months
  • Users without graduation month/year are ignored
  • Users with a non-matching graduation month/year are ignored
  • Users who already have an Alumni record are ignored
  • Users who already have an AlumniCandidate are ignored
  • The endpoint response includes the number of alumni candidates created
  • Unit/integration tests cover matching month/year, missing graduation date, non-matching graduation date, existing alumni, and duplicate candidate cases

Additional Context

Relevant existing files:

  • next/lib/services/alumniCandidateService.ts
  • next/lib/authOptions.ts
  • next/app/api/user/route.ts
  • next/app/api/elections/[id]/send-officer-invites/route.ts
  • next/app/(main)/dashboard/new-semester/[electionId]/NewSemesterClient.tsx
## Problem Auto-generated alumni review rows currently appear from profile/sign-in activity, not from the election handoff flow. Current behavior: - `next/lib/services/alumniCandidateService.ts` creates an `AlumniCandidate` when `hasTermPassed(graduationTerm, graduationYear)` is true - `maybeCreateAlumniCandidate()` runs from `next/lib/authOptions.ts` on sign-in - `maybeCreateAlumniCandidate()` also runs from `next/app/api/user/route.ts` after profile updates That means a pending alumni review can appear just because a user signs in or edits their profile after their graduation term has passed. The desired behavior is narrower: auto-generated alumni requests should appear only as part of the end-of-election / new-semester handoff when the graduating student is in the graduation month/year associated with that election cycle. Example: if a student graduates in **May 2026**, then clicking the end-of-election / send-invites button for the May 2026 election cycle should generate their automatic alumni review row. ## Proposed Solution Move automatic alumni candidate generation into the post-election handoff flow. Likely trigger point: - `POST /api/elections/[id]/send-officer-invites`, used by `next/app/(main)/dashboard/new-semester/[electionId]/NewSemesterClient.tsx` when SE Office clicks **Send invites** If the product flow changes to combine certification, new-semester start, and invite dispatch into a single end-election action, put the alumni generation in that single orchestrator instead. The key requirement is that the generation happens from the election-cycle handoff button, not from normal sign-in/profile-update side effects. ## Eligibility Rule Create an auto alumni candidate only when both are true: 1. The user has provided a graduation month and graduation year 2. The graduation month/year matches the current election cycle's handoff month/year Suggested election-cycle date source: - Prefer `Election.votingCloseAt` or `Election.certifiedAt` as the election-cycle reference date, and document the chosen source - Compare `(graduationMonth, graduationYear)` to that reference month/year Important current-data note: the schema currently stores `graduationTerm` and `graduationYear`, not a precise graduation month. This issue should either add a `graduationMonth` field or explicitly define a reliable term-to-month mapping before implementing the month/year check. ## Scope In scope: - Stop creating automatic alumni candidates from sign-in - Stop creating automatic alumni candidates from ordinary profile updates - Add or derive a precise graduation month for the user profile - Add a batch generator that runs during election handoff / officer invite dispatch - Generate pending `AlumniCandidate` rows only for users whose graduation month/year matches the election-cycle reference month/year - Avoid duplicate candidates for users who already have an `Alumni` record or an existing candidate - Return a count of generated alumni candidates from the handoff endpoint so the UI can toast/report it - Update the handoff UI copy to mention alumni candidates generated, if any Out of scope: - Automatically approving alumni candidates - Sending alumni-specific emails unless added as a separate follow-up - Changing the manual public alumni request form ## Acceptance Criteria - [ ] Signing in no longer creates an automatic alumni candidate - [ ] Editing a profile no longer creates an automatic alumni candidate just because the graduation date has passed - [ ] Clicking the election handoff / send-invites button creates pending alumni candidates for users graduating in the election-cycle month/year - [ ] A user graduating in May 2026 is generated during the May 2026 election handoff, not before and not for other election months - [ ] Users without graduation month/year are ignored - [ ] Users with a non-matching graduation month/year are ignored - [ ] Users who already have an `Alumni` record are ignored - [ ] Users who already have an `AlumniCandidate` are ignored - [ ] The endpoint response includes the number of alumni candidates created - [ ] Unit/integration tests cover matching month/year, missing graduation date, non-matching graduation date, existing alumni, and duplicate candidate cases ## Additional Context Relevant existing files: - `next/lib/services/alumniCandidateService.ts` - `next/lib/authOptions.ts` - `next/app/api/user/route.ts` - `next/app/api/elections/[id]/send-officer-invites/route.ts` - `next/app/(main)/dashboard/new-semester/[electionId]/NewSemesterClient.tsx`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
SSE/WebsiteTheSSEquel#502
No description provided.