Skip to content

Conversation

@pezholio
Copy link
Contributor

@pezholio pezholio commented Nov 5, 2025

This develops the spike outlined in #7347 to allow us to use Content Blocks within Smart Answers. A lot of the integration with the content blocks has been outsourced to the Content Block Tools Gem, specifically the functionality added in alphagov/govuk_content_block_tools#112.

Most of the actual work in this PR is adding a ContentBlockDetector class which, when a Smart Answer is published to Publishing API, looks to see what content blocks are used in a Smart Answer and publishes the relevant links so they can be shown as related content in Content Block Manager, eg:

image

We currently aren't using any blocks in the code at the moment, but this sets us up so using content blocks is easy and seamless.

@govuk-ci govuk-ci temporarily deployed to smart-answers-pr-7378 November 5, 2025 09:39 Inactive
@pezholio pezholio force-pushed the CM-618-develop-smart-answers-spike branch from 8c5f693 to 770a92f Compare November 5, 2025 09:41
@govuk-ci govuk-ci temporarily deployed to smart-answers-pr-7378 November 5, 2025 09:42 Inactive
@pezholio pezholio force-pushed the CM-618-develop-smart-answers-spike branch from 770a92f to da83bf9 Compare November 5, 2025 09:44
@govuk-ci govuk-ci temporarily deployed to smart-answers-pr-7378 November 5, 2025 09:44 Inactive
We’ll need this to fetch content blocks using their embed codes.
@pezholio pezholio force-pushed the CM-618-develop-smart-answers-spike branch from da83bf9 to c0d8391 Compare November 10, 2025 11:37
@govuk-ci govuk-ci temporarily deployed to smart-answers-pr-7378 November 10, 2025 11:37 Inactive
This uses static analysis of code to fetch all the files associated
with a flow, reading the content of those files, and checking if any
content blocks embed codes have been used in them. If they have, we
return the content blocks in question.

I’ve added some YARD-compliant comments to the code, so it’s clear as
to what’s going on, as well as made a bunch of methods that would
otherwise be considered private to make unit testing easier.

In the next commit, we’ll use these to create links when publishing
smart answers in Publishing API.
This allows us to send the content IDs of any content blocks that are
used in a smart answer as links, so Content Block Manager knows that
the blocks are used in a particular Smart Answer.
@pezholio pezholio force-pushed the CM-618-develop-smart-answers-spike branch from c0d8391 to 595a9e4 Compare November 11, 2025 15:01
@govuk-ci govuk-ci temporarily deployed to smart-answers-pr-7378 November 11, 2025 15:01 Inactive
@govuk-ci govuk-ci temporarily deployed to smart-answers-pr-7378 November 11, 2025 16:37 Inactive
@pezholio pezholio marked this pull request as ready for review November 12, 2025 15:00
Copy link
Contributor

@Tetrino Tetrino left a comment

Choose a reason for hiding this comment

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

Looks good to me! Sensible solution.

I am a little lost on why we need the calculators themselves at this stage but they're not doing any harm and I see there is future relevant functionality in the planning so I'm fine with the references being there.

@pezholio pezholio merged commit 5954613 into main Nov 13, 2025
12 checks passed
@pezholio pezholio deleted the CM-618-develop-smart-answers-spike branch November 13, 2025 10:02
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.

4 participants