#26 Cycle Model Database#33
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: b-at-neu <144247685+b-at-neu@users.noreply.github.com>
| data: Omit<Application, 'id' | 'createdAt' | 'nominationFormPdfUrl'>, | ||
| data: Omit<Application, 'id' | 'createdAt' | 'nominationFormPdfUrl' | 'cycleId'>, | ||
| ) { | ||
| const activeCycle = await db.cycle.findFirst({ where: { isActive: true } }); |
There was a problem hiding this comment.
Lets create a getCycle function for this
There was a problem hiding this comment.
Actually just use getActiveCycle
There was a problem hiding this comment.
Done in 6114982. All inline db.cycle.findFirst calls have been replaced with getActiveCycle() from lib/data/cycles.ts.
| import { db } from '@/lib/db'; | ||
|
|
||
| export async function getActiveCycle() { | ||
| return db.cycle.findFirst({ |
There was a problem hiding this comment.
Throw an error if there is no cycle
There was a problem hiding this comment.
Actually, just create a default cycle
There was a problem hiding this comment.
Done in 6114982. getActiveCycle() now creates a default { name: 'Current Cycle', isActive: true } cycle if none is found, instead of returning null.
| throw new Error(`This nominator has already nominated ${data.nominee}`); | ||
| } | ||
|
|
||
| const activeCycle = await db.cycle.findFirst({ where: { isActive: true } }); |
There was a problem hiding this comment.
All of these cases can use getActiveCycle instead
There was a problem hiding this comment.
Done in 6114982. Updated lib/data/nominations.ts, lib/data/endorsements.ts, lib/data/applications.ts, and lib/actions/nominations.ts to all use getActiveCycle().
Co-authored-by: b-at-neu <144247685+b-at-neu@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
| // Fixed ID for the singleton settings record | ||
| const SETTINGS_ID = 'default'; | ||
| // Default cycle ID used in initial migration | ||
| const DEFAULT_CYCLE_ID = 'default-cycle'; |
There was a problem hiding this comment.
Lets get the active cycle here too
There was a problem hiding this comment.
Done in ea31045. updateSettings now calls getActiveCycle() and upserts by cycleId instead of the hardcoded SETTINGS_ID/DEFAULT_CYCLE_ID.
| // Fixed ID for the singleton settings record | ||
| const SETTINGS_ID = 'default'; | ||
| // Default cycle ID used in initial migration | ||
| const DEFAULT_CYCLE_ID = 'default-cycle'; |
There was a problem hiding this comment.
lets use the active cycle
There was a problem hiding this comment.
Done in ea31045. getSettings now calls getActiveCycle() and upserts by cycleId.
Co-authored-by: b-at-neu <144247685+b-at-neu@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…pilot/create-cycle-model-structure
….com/b-at-neu/senate-path into copilot/create-cycle-model-structure
prisma/schema.prismato add Cycle model and cycleId FKs to Application, Nomination, Endorsement, Settingslib/data/cycles.tswithgetActiveCycle()(creates default cycle if none exists) andgetCycles()helperslib/data/settings.tsto usegetActiveCycle()and upsert bycycleIdinstead of hardcoded IDlib/actions/settings.tsto usegetActiveCycle()and upsert bycycleIdinstead of hardcoded IDlib/data/applications.tsto usegetActiveCycle()on application createlib/data/nominations.tsto usegetActiveCycle()on nomination createlib/data/endorsements.tsto usegetActiveCycle()on endorsement createlib/actions/nominations.tsto usegetActiveCycle()on nomination createOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.