Skip to content

feat(surveys): open/close scheduling and response cap (Issue 1465) - #1476

Open
leahpeker wants to merge 2 commits into
mainfrom
feat-survey-scheduling-cap
Open

feat(surveys): open/close scheduling and response cap (Issue 1465)#1476
leahpeker wants to merge 2 commits into
mainfrom
feat-survey-scheduling-cap

Conversation

@leahpeker

Copy link
Copy Markdown
Collaborator

Summary

Closes #1465

  • Adds opens_at, closes_at (nullable datetimes) and max_responses (nullable int) to Survey, with a migration and closes_at > opens_at validation on create/patch.
  • Adds a single survey_is_open(survey, now, check_cap=...) helper in _survey_helpers.py used by both public endpoints (get_survey_public, submit_survey_response) so the closed/scheduled/at-cap window is enforced consistently. check_cap is skipped for an existing one-per-user response so an upsert isn't blocked once the cap is hit.
  • Exposes the three fields on SurveyIn/SurveyPatchIn/SurveyOut/SurveyListOut, and adds a survey.closes_before_opens validation code (+ FE message).
  • Adds the three fields to the create-survey dialog (SurveyAdminListScreen.tsx) using the existing DateTimePicker component, and a scheduled / active / closed status badge (surveyStatus.ts) on the admin list.
  • Regenerates types.gen.ts, validationCodes.gen.ts, validation_codes.json, openapi_schema.json to match.

Out of scope (left for sibling PRs already in flight): the edit-survey dialog (#1459) and the "closed" state on public 404s (#1460) — the survey_is_open helper is written so #1460 can swap in its closed-state response without touching call sites.

Test plan

  • Backend: TestSurveyScheduling covers before-open, after-close, at-cap, upsert-not-blocked-by-cap, and inactive-still-closed; TestSurveyScheduleAdmin covers create/patch validation (closes_before_opens, cap ge=1), field round-trip, and clearing all three fields via PATCH.
  • Frontend: SurveyAdminListScreen.test.tsx covers the surveyStatus helper (5 cases) and the create dialog (renders the three fields; submits max_responses as a number or null).
  • Ran locally and passing: make agent-lint, make agent-typecheck, make agent-complexity, make agent-check-codes, make agent-test (2219 passed; the only failures are 7 pre-existing/unrelated tests documented in the Makefile as SQLite-only limitations — test_sse.py needs pg_notify, test_rsvp_capacity_race.py/test_poll_finalize_race.py need real select_for_update row locking), make agent-frontend-lint, make agent-frontend-typecheck.
  • Not run to a clean finish locally: make agent-frontend-test / make agent-frontend-ci. Two separate runs each showed a handful of different, unrelated test files (PublicRsvpSection, OnboardingScreen, WelcomeTemplateEditorDialog, EventFormHosts) timing out at 5s under parallel CPU load — none touch surveys, and the new survey test file plus the full suite pass cleanly when run in isolation. Deferring final verification to GitHub Actions CI on this PR rather than re-running locally.

Adds opens_at, closes_at, and max_responses to Survey, with a single
survey_is_open helper enforcing the window/cap on both public
endpoints. The cap check is skippable so an existing one-per-user
response can still be upserted after the cap is hit.
…sue 1465)

Adds opens_at/closes_at/max_responses to the create-survey dialog and
a scheduled/active/closed status badge to the admin list, plus the
regenerated OpenAPI types and validation-code catalog for the new
survey.closes_before_opens code.
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.

Add open/close scheduling and a response cap to surveys

1 participant