feat(surveys): open/close scheduling and response cap (Issue 1465) - #1476
Open
leahpeker wants to merge 2 commits into
Open
feat(surveys): open/close scheduling and response cap (Issue 1465)#1476leahpeker wants to merge 2 commits into
leahpeker wants to merge 2 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1465
opens_at,closes_at(nullable datetimes) andmax_responses(nullable int) toSurvey, with a migration andcloses_at > opens_atvalidation on create/patch.survey_is_open(survey, now, check_cap=...)helper in_survey_helpers.pyused by both public endpoints (get_survey_public,submit_survey_response) so the closed/scheduled/at-cap window is enforced consistently.check_capis skipped for an existing one-per-user response so an upsert isn't blocked once the cap is hit.SurveyIn/SurveyPatchIn/SurveyOut/SurveyListOut, and adds asurvey.closes_before_opensvalidation code (+ FE message).SurveyAdminListScreen.tsx) using the existingDateTimePickercomponent, and ascheduled/active/closedstatus badge (surveyStatus.ts) on the admin list.types.gen.ts,validationCodes.gen.ts,validation_codes.json,openapi_schema.jsonto 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_openhelper is written so #1460 can swap in its closed-state response without touching call sites.Test plan
TestSurveySchedulingcovers before-open, after-close, at-cap, upsert-not-blocked-by-cap, and inactive-still-closed;TestSurveyScheduleAdmincovers create/patch validation (closes_before_opens, capge=1), field round-trip, and clearing all three fields via PATCH.SurveyAdminListScreen.test.tsxcovers thesurveyStatushelper (5 cases) and the create dialog (renders the three fields; submitsmax_responsesas a number ornull).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.pyneedspg_notify,test_rsvp_capacity_race.py/test_poll_finalize_race.pyneed realselect_for_updaterow locking),make agent-frontend-lint,make agent-frontend-typecheck.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.