Skip to content

(CM-413) Fetch organisations from Publishing API#7

Merged
pezholio merged 20 commits into
mainfrom
CM-413-fetch-organisations-from-publishing-api
Sep 1, 2025
Merged

(CM-413) Fetch organisations from Publishing API#7
pezholio merged 20 commits into
mainfrom
CM-413-fetch-organisations-from-publishing-api

Conversation

@pezholio
Copy link
Copy Markdown
Contributor

@pezholio pezholio commented Aug 28, 2025

Now we’re moving away from Whitehall, we no longer have direct access to Organisations in the Whitehall database. We need to fetch these from Publishing API instead. This changes the Organisation class to a data class which fetches the Organisation documents directly from the Publishing API (behind a cache). There's a bit of unpicking to do in the rest of the codebase (mainly related to tests), so apologies for the number of commits!

We still need to fix linking to organisations (see

), but I'll do this in a separate PR

@pezholio pezholio requested a review from edavey August 28, 2025 15:49
@pezholio pezholio force-pushed the CM-413-fetch-organisations-from-publishing-api branch 4 times, most recently from c2b1371 to 8ce0c33 Compare August 28, 2025 16:13
Copy link
Copy Markdown
Collaborator

@edavey edavey left a comment

Choose a reason for hiding this comment

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

Nice work, rather fiddly!

},
]

assert_equal taggable_organisations_container([]), expected
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the signature in mini-test is assert_equal(expected, actual)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call, I always forget which way round that is!

In the next commit we’ll fetch organisation data from the API
This fetches and caches (for 1 day) organisations from Publishing API,
marshalling them into `Organisation` objects. The tests set up the
cache, so we can ensure it works correctly.
I’ve also updated the factory to support a generic Ruby class, and
remove the `ministerial_department` and `non_ministerial_department`
scopes.
This drops the `organisations` and `content_block_edition_organisations`
tables
This removes the relation, and allows the Organisation object to be
returned
Also, set `lead_organisation_id` rather than `organisation`
This was left over from the migration
The content_id field is now called just `id`
We no longer need to join, and can just query by the ID
We may want to put something like this back at a later date, but
let’s leave it for now
We are now fetching organisations via the helper
@pezholio pezholio force-pushed the CM-413-fetch-organisations-from-publishing-api branch from 8ce0c33 to 7cbc8ee Compare September 1, 2025 09:22
@pezholio pezholio merged commit 439da93 into main Sep 1, 2025
22 checks passed
@pezholio pezholio deleted the CM-413-fetch-organisations-from-publishing-api branch September 1, 2025 09: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.

2 participants