feat: update contract_version to read from config (#38) #44

Merged
forgejo_admin merged 1 commit from 38-update-contract-version into main 2026-04-05 01:38:41 +00:00
Contributor

Summary

Update the sign endpoint to derive contract_version from team.contract_config (season + variant) instead of hardcoding version strings based on team name patterns. Keeps the existing team-name-based fallback for teams with NULL config.

Changes

  • src/routes/contract/[token]/sign/+server.ts — Query contract_config column alongside name from teams table. When contract_config.variant and contract_config.season are present, construct version string from config data. Otherwise fall back to existing teamName.includes() logic.

Test Plan

  • npm test — 30/30 tests pass
  • npm run check — no new type errors (pre-existing @types/node / @types/pg errors unchanged)
  • Verify in production: teams with contract_config set get data-driven version; teams without config get fallback behavior

Review Checklist

  • Code follows project conventions
  • Tests pass (npm test — 30/30)
  • Type check passes (no new errors)
  • Change is backward-compatible (NULL config falls back to existing logic)

Closes #38

N/A

## Summary Update the sign endpoint to derive `contract_version` from `team.contract_config` (season + variant) instead of hardcoding version strings based on team name patterns. Keeps the existing team-name-based fallback for teams with NULL config. ## Changes - `src/routes/contract/[token]/sign/+server.ts` — Query `contract_config` column alongside `name` from teams table. When `contract_config.variant` and `contract_config.season` are present, construct version string from config data. Otherwise fall back to existing `teamName.includes()` logic. ## Test Plan - `npm test` — 30/30 tests pass - `npm run check` — no new type errors (pre-existing `@types/node` / `@types/pg` errors unchanged) - Verify in production: teams with `contract_config` set get data-driven version; teams without config get fallback behavior ## Review Checklist - [x] Code follows project conventions - [x] Tests pass (`npm test` — 30/30) - [x] Type check passes (no new errors) - [x] Change is backward-compatible (NULL config falls back to existing logic) ## Related Closes #38 ## Related Notes N/A
Derive contract version from contract_config.season + contract_config.variant
when available, falling back to team-name-based logic for teams with NULL config.

Closes #38

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Contributor

QA Review — PR #44

Diff reviewed: 1 file, +18/-8 lines in src/routes/contract/[token]/sign/+server.ts

Findings

  1. Correct: Query updated to SELECT name, contract_config — matches the spec from #38.
  2. Correct: Config-driven path checks both teamConfig?.variant and teamConfig?.season before using them.
  3. Correct: Year extraction via regex (/\d{4}/) with '2026' fallback is defensive.
  4. Correct: Fallback path preserves exact existing behavior (team-name-based includes() logic).
  5. No new type errors: Pre-existing @types/node / @types/pg issues are unchanged.
  6. Tests: 30/30 pass.
  7. Nit (non-blocking): The "spring" segment is hardcoded in the config-driven path (${year}-spring-${teamConfig.variant}-v1). If a future season drops "spring," this will need updating. Acceptable for now since all current contracts are spring.

VERDICT: APPROVED

## QA Review — PR #44 **Diff reviewed:** 1 file, +18/-8 lines in `src/routes/contract/[token]/sign/+server.ts` ### Findings 1. **Correct:** Query updated to `SELECT name, contract_config` — matches the spec from #38. 2. **Correct:** Config-driven path checks both `teamConfig?.variant` and `teamConfig?.season` before using them. 3. **Correct:** Year extraction via regex (`/\d{4}/`) with `'2026'` fallback is defensive. 4. **Correct:** Fallback path preserves exact existing behavior (team-name-based `includes()` logic). 5. **No new type errors:** Pre-existing `@types/node` / `@types/pg` issues are unchanged. 6. **Tests:** 30/30 pass. 7. **Nit (non-blocking):** The `"spring"` segment is hardcoded in the config-driven path (`${year}-spring-${teamConfig.variant}-v1`). If a future season drops "spring," this will need updating. Acceptable for now since all current contracts are spring. ### VERDICT: APPROVED
forgejo_admin deleted branch 38-update-contract-version 2026-04-05 01:38:41 +00:00
Sign in to join this conversation.
No reviewers
No labels
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
ldraney/westside-contracts!44
No description provided.