Repository navigation
Add v3 endpoint for fetching forms with delivery schedule - #3239
Conversation
b34d26b to
8d60427
Compare
|
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 |
8d60427 to
48d9f94
Compare
There was a problem hiding this comment.
🟢 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/:schedulefor 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
Add a new controller to allow forms-runner to fetch all forms with a given delivery schedule.
48d9f94 to
7a4cf43
Compare
|
🎉 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 For the sign in details and more information, see the review apps wiki page. |

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/:schedulewhere:scheduleis one ofimmediate,dailyorweekly.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
statearecurrentanddraft-liveandarchivedform documents will show up ascurrent. This matches the terminology we use in the delivery configurations endpoint. In forms-runner if a form is submitted inpreview-archivedmode we want to check it against the most recent live or archived form documentThings to consider when reviewing