Skip to content

Add v3 endpoint for fetching forms with delivery schedule - #3239

Merged
DavidBiddle merged 3 commits into
mainfrom
add-v3-endpoint-for-fetching-forms-with-delivery-schedule
Oct 29, 2026
Merged

DavidBiddle merged 3 commits into
mainfrom
add-v3-endpoint-for-fetching-forms-with-delivery-schedule

Conversation

@DavidBiddle

@DavidBiddle DavidBiddle commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this pull request solve?

Trello card: https://trello.com/c/P7bDQZTP/3248-get-submission-delivery-configuration-from-latest-live-version-of-the-form-in-forms-runner

Adds a new v3 API endpoint that will return a list of forms which have a given delivery schedule.

The endpoint is at /api/v3/forms/with-delivery-schedule/:schedule where :schedule is one of immediate, daily or weekly.

It will return a JSON response listing form IDs and state for any current or draft FormDocuments with the specified delivery schedule:

[
  {
    "form_id": 1,
    "state": "current"
  },
  {
    "form_id": 2,
    "state": "current"
  },
  {
    "form_id": 3,
    "state": "current"
  },
  {
    "form_id": 8,
    "state": "current"
  },
  {
    "form_id": 5,
    "state": "current"
  },
  {
    "form_id": 6,
    "state": "current"
  },
  {
    "form_id": 9,
    "state": "current"
  },
  {
    "form_id": 7,
    "state": "current"
  },
  {
    "form_id": 4,
    "state": "current"
  },
  {
    "form_id": 1,
    "state": "draft"
  },
  {
    "form_id": 2,
    "state": "draft"
  },
  {
    "form_id": 3,
    "state": "draft"
  },
  {
    "form_id": 5,
    "state": "draft"
  },
  {
    "form_id": 6,
    "state": "draft"
  },
  {
    "form_id": 7,
    "state": "draft"
  },
  {
    "form_id": 8,
    "state": "draft"
  },
  {
    "form_id": 9,
    "state": "draft"
  },
  {
    "form_id": 4,
    "state": "draft"
  }
]

Note that the only possible values for state are current and draft - live and archived form documents will show up as current. This matches the terminology we use in the delivery configurations endpoint. In forms-runner if a form is submitted in preview-archived mode we want to check it against the most recent live or archived form document

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Do the end to end tests need updating before these changes will pass?
  • Has all relevant documentation been updated?

@DavidBiddle
DavidBiddle force-pushed the add-v3-endpoint-for-fetching-forms-with-delivery-schedule branch from b34d26b to 8d60427 Compare October 22, 2026 15:51
@DavidBiddle
DavidBiddle marked this pull request as draft October 23, 2026 08:59
@DavidBiddle

DavidBiddle commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Moving this back to draft because I think I need to rework it - if this and the corresponding runner work were implemented there's a risk of lost submissions (documented on the trello card)

Edit: I investigated and this was a false alarm - sticking with the current implementation

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The remaining feedback concerns non-blocking test scenario and description corrections, with no identified functional defects.

3 open issues
What changed in this PR

Adds a v3 API endpoint for forms-runner to find forms by delivery schedule, returning matching draft and latest live or archived documents as draft and current states.

Changes:

  • Adds /api/v3/forms/with-delivery-schedule/:schedule for immediate, daily, and weekly schedules.
  • Queries document delivery configurations and combines matching form IDs and states.
  • Adds delivery configuration factory traits and model/request coverage.
File Description
spec/​requests/​api/​v3_form_documents_controller_spec.rb Tests endpoint responses across document states and no-match cases.
spec/​models/​form_spec.rb Tests delivery traits, schedule queries, and combined results.
spec/​factories/​models/​forms.rb Adds S3 and daily/weekly email delivery traits.
config/​routes.rb Adds the schedule-filtered route while preserving existing endpoints.
app/​models/​form.rb Adds schedule queries and maps document tags to response states.
app/​controllers/​api/​v3_form_documents_controller.rb Adds the action returning matching forms as JSON.

Review effort: Balanced

Comment thread spec/models/form_spec.rb Resolved
Comment thread spec/models/form_spec.rb Resolved
Comment thread spec/models/form_spec.rb Resolved
Comment thread app/models/form.rb Resolved
Comment thread config/routes.rb Resolved
Add a new controller to allow forms-runner to fetch all forms with a
given delivery schedule.
@DavidBiddle
DavidBiddle force-pushed the add-v3-endpoint-for-fetching-forms-with-delivery-schedule branch from 48d9f94 to 7a4cf43 Compare October 29, 2026 10:06
@github-actions

Copy link
Copy Markdown

🎉 A review copy of this PR has been deployed! You can reach it at: https://pr-3239.admin.review.forms.service.gov.uk/

It may take 5 minutes or so for the application to be fully deployed and working. If it still isn't ready
after 5 minutes, there may be something wrong with the ECS task. You will need to go to the integration AWS account
to debug, or otherwise ask an infrastructure person.

For the sign in details and more information, see the review apps wiki page.

@DavidBiddle
DavidBiddle added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit fd5b24c Oct 29, 2026
7 checks passed
@DavidBiddle
DavidBiddle deleted the add-v3-endpoint-for-fetching-forms-with-delivery-schedule branch October 29, 2026 16:30
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.

3 participants