Skip to content

Add FormRepository pages method#1725

Merged
SamJamCul merged 2 commits intomainfrom
forms-pages-via-repository
Jan 23, 2025
Merged

Add FormRepository pages method#1725
SamJamCul merged 2 commits intomainfrom
forms-pages-via-repository

Conversation

@SamJamCul
Copy link
Copy Markdown
Contributor

What problem does this pull request solve?

Trello card: https://trello.com/c/XJVoEeTw/2075-add-form-pages-to-form-repository

Adds a FormRepository pages method, which requests a form's pages via the form model. This is then used throughout the app to replace any requests for form pages that we're currently making.

Things to consider when reviewing

It was a little fiddly to find all the places we're getting form pages, and the way activeresource works makes testing that we're actually stubbing out a request is also quite fiddly.

There may be some tests where technically we could have removed the stubbing, and they still would have worked, as the way we factory build forms means they come with pages already, so a call for .pages wouldn't result in an API request. I've tried to still replace any possible circumstances where we could have made an API request with the FormRepository version.

I'm also not sure if there'll be a performance hit with some of this, mainly around the conditions stuff. There are a few places where we're looking at a form's pages, and if each of those hits the API, we might (big might) see some slowdown. I've tried testing locally which was fine, but I'm very tempted to test on dev to see if it's fine.

  • 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?

@SamJamCul SamJamCul force-pushed the forms-pages-via-repository branch 2 times, most recently from 8703e14 to 6611b22 Compare January 22, 2025 10:52
Copy link
Copy Markdown
Contributor

@lfdebrux lfdebrux left a comment

Choose a reason for hiding this comment

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

This works for me locally, thanks for putting it together.

Adds a pages method to the FormRepository service. This allows accessing a form's pages indirectly through the repository, rather than directly through the model - which will make the API-admin switching work easier
Replaces any calls to the Form model for pages with a FormRepository.pages method call instead.
@SamJamCul SamJamCul force-pushed the forms-pages-via-repository branch from 6611b22 to 00d02d4 Compare January 23, 2025 15:13
@SamJamCul SamJamCul enabled auto-merge January 23, 2025 15:13
@sonarqubecloud
Copy link
Copy Markdown

@SamJamCul SamJamCul merged commit 547a0e5 into main Jan 23, 2025
@SamJamCul SamJamCul deleted the forms-pages-via-repository branch January 23, 2025 15:18
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