-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firebreak - Add reports to download live form data as CSV files #1681
base: main
Are you sure you want to change the base?
Conversation
5729c92
to
54dd2ee
Compare
689c5de
to
d15dc1d
Compare
b5bb6c9
to
1b3e8ae
Compare
This report downloads a CSV file containing data about all live forms. This calls the forms-api "/api/v2/form-documents" endpoint to get the form document objects for all live forms. We get the form documents rather than the form model as the form document represents the state of the live form that is served to form fillers, whereas the form model might have changes that have been made to a draft version of the form. The forms-api endpoint supports pagination. Use this to avoid sending all form documents in a single large API response - default to 100 results per request page. To make requests to forms-api, use Net:HTTP rather than ActiveResource. I attempted to use ActiveResource at first but this required an additional gem and some additional hacking at to be able to consume the headers for pagination. When we consume the data from forms-admin, add in details about the organisation and group for the form and manipulate some of the data to produce a useful CSV report. For the tests, use a JSON fixutre file that was generated by making a real API request to forms-api with the data from the database seeds. Once we have transitioned to using the V2 API in forms-admin, it might make more sense to use factories to generate the response.
This report downloads a CSV file containing data about all questions in live forms. This works the same way as the report for getting data about forms themselves, but includes a row in the CSV per question in a live form.
Move the `UserReportService` in to a `reports` directory and under a `Reports` module to group the different reports services together.
1b3e8ae
to
a6d2190
Compare
Quality Gate passedIssues Measures |
Looks good from a content perspective. This will be so useful - thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes make sense to me, the commits are well structured & documented, and the report download works on my local machine 🎉
What problem does this pull request solve?
Trello card: https://trello.com/c/mPtJhtWq/
Add 2 reports to get all data about live forms as a CSV, and to get all questions in all live forms as a CSV.
The intention of this is that it should make it easier to analyse data about forms and questions that exist on the platform without having to spend time to make dedicated reports. It should be quick and easy to add additional columns into these CSV reports as we add new features.
These reports call the forms-api "/api/v2/form-documents" endpoint added in alphagov/forms-api#663 to get the form document objects for all live forms. We get the form documents rather than the form model as the form document represents the state of the live form that is served to form fillers, whereas the form model might have changes that have been made to a draft version of the form.
The forms-api endpoint supports pagination. Use this to avoid sending all form documents in a single large API response - default to 100 results per request page.
To make requests to forms-api, use Net:HTTP rather than ActiveResource. I attempted to use ActiveResource at first but this required an additional gem and some additional hacking at to be able to consume the headers for pagination.
Example CSVs:
live_forms_report-2025-01-03 12_59_53 UTC.csv
live_questions_report-2025-01-03 13_03_47 UTC.csv
Relies on forms-api pull request: alphagov/forms-api#663
Things to consider when reviewing