Skip to content
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 report to get all live forms #663

Merged
merged 2 commits into from
Jan 6, 2025

Conversation

stephencdaly
Copy link
Contributor

@stephencdaly stephencdaly commented Dec 23, 2024

What problem does this pull request solve?

Trello card: https://trello.com/c/mPtJhtWq/

Add GET api/v2/form-documents API endpoint to retrieve all for documents by tag for the purpose of generating reports in forms-admin. This uses the "kaminari" gem to paginate the results to avoid sending all the form data in one API response.

The API endpoint accepts the following query parameters:

  • tag: the tag to filter form documents by. If not provided, all form documents with all tags are returned
  • page: the page of results to get
  • per_page: the number of results to return per page

We return all the form data for forms-admin to process so that organisation and group data can be added to the report.

Related admin PR to add the report: alphagov/forms-admin#1681

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?
  • Has all relevant documentation been updated?

@stephencdaly stephencdaly force-pushed the add-csv-download-reports branch from cafee3d to fe77906 Compare December 23, 2024 15:45
@stephencdaly stephencdaly changed the title Add report to get all live forms Firebreak - Add report to get all live forms Dec 23, 2024
@stephencdaly stephencdaly force-pushed the add-csv-download-reports branch 2 times, most recently from 6b8710c to 9521483 Compare December 23, 2024 16:01
@stephencdaly stephencdaly force-pushed the add-csv-download-reports branch 6 times, most recently from 4ebb5de to 352fa96 Compare January 3, 2025 13:28
Add GET `api/v2/form-documents` API endpoint to retrieve all for
documents by tag for the purpose of generating reports in forms-admin.
This uses the  "kaminari" gem to paginate the results to avoid sending
all the form data in one API response.

The API endpoint accepts the following query parameters:
- `tag`: the tag to filter form documents by. If not provided, all
form documents with all tags are returned
- `page`: the page of results to get
- `per_page`: the number of results to return per page
@stephencdaly stephencdaly force-pushed the add-csv-download-reports branch from 352fa96 to 0e3e46b Compare January 3, 2025 13:36
@stephencdaly stephencdaly marked this pull request as ready for review January 3, 2025 14:10
When dealing with pagination, if we do not order the results there is
the potential for results to move around in the order that the
database would return them, meaning results could be duplicated or
omitted when navigating through pages.

Order the results by their ID, as this is indexed by default and any
new records that are created when we are navigating through the pages
of results will be added at the end.
@stephencdaly stephencdaly force-pushed the add-csv-download-reports branch from 0e3e46b to 0dea82f Compare January 3, 2025 15:48
Copy link

sonarqubecloud bot commented Jan 3, 2025

Copy link
Contributor

@DavidBiddle DavidBiddle left a comment

Choose a reason for hiding this comment

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

Raised a comment about one of the commit messages, but otherwise looks great and works for me locally

@stephencdaly stephencdaly merged commit ce4f637 into main Jan 6, 2025
4 checks passed
@stephencdaly stephencdaly deleted the add-csv-download-reports branch January 6, 2025 09:43
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.

2 participants