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

Add substitute event for queue consumers #2664

Merged
merged 2 commits into from
Apr 11, 2024
Merged

Conversation

callumknights
Copy link
Contributor

@callumknights callumknights commented Mar 5, 2024

This PR is largely a copy of #2652 that I made to get my head around Richards thinking.

Trello: https://trello.com/c/xaN2Dhwk/1005-emit-an-event-when-documents-are-unpublished-through-subsitution

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

This application is owned by the publishing platform team. Please let us know in #govuk-publishing-platform when you raise any PRs.

Follow these steps if you are doing a Rails upgrade.

@callumknights callumknights force-pushed the add-substitute-event branch 4 times, most recently from a2dadc2 to f173321 Compare April 10, 2024 13:51
Copy link
Member

@brucebolt brucebolt 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 👍. I've just added a few really small comments about the layout of the commits, but otherwise the code looks fine.

I think you'll also need to auto-regenerate the schemas again, because it looks like topic_taxonomy_taxons have been removed since they were last generated and there's now a failing test because of that.

@@ -79,7 +79,10 @@ def message_queue_presenter
when "redirect" then redirect_presenter
when "gone" then gone_presenter
when "vanish" then vanish_presenter
else content_presenter
when "substitute" then vanish_presenter
Copy link
Member

Choose a reason for hiding this comment

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

Should this not be substitute_presenter?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see the substitute_presenter method was added in a later commit. Maybe this first commit should just add the logging, then the when "substitute" case could be added in the same commit as the substitute_presenter method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ultimately just decided to merge everything to do with the new unpublishing type into one commit, doesn't make much sense to split it 👍

app/commands/v2/publish.rb Show resolved Hide resolved
@callumknights callumknights force-pushed the add-substitute-event branch 3 times, most recently from 73d920e to 4fff7e5 Compare April 10, 2024 15:04
Copy link
Member

@brucebolt brucebolt left a comment

Choose a reason for hiding this comment

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

Thanks, the two commits are much easier to follow.

Copy link
Contributor

@richardTowers richardTowers left a comment

Choose a reason for hiding this comment

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

I think we also need to switch the logic up a bit in message_queue_presenter - there's an issue at the moment where redirects take priority over unpublishings, which will mean we send "redirect" payloads when we're substituting old redirects, instead of sending "substitute" payloads.

Luckily, our test case is a redirect, so this is eash to show with an addition to the test.

Some commits to show what I mean in another branch:

https://github.com/alphagov/publishing-api/compare/add-substitute-event..towers/add-substitute-event

(Feel free to merge these into this PR if you're happy with them)

@richardTowers
Copy link
Contributor

I think there's also some refactoring that could be done to move some of the duplicated code into SubstitutionHelper, which I've sketched out on this branch - I think that could be taken out of scope an addressed in a future PR though.

Copy link
Contributor

@richardTowers richardTowers 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 - thanks for the perseverence on this 🙇🏻

It's probably worth getting back to @csutter as this gets deployed, as he might have an idea of a good way to test it / let us know whether the new behaviour works well enough for the search use case.

@callumknights callumknights merged commit f8e2a62 into main Apr 11, 2024
43 checks passed
@callumknights callumknights deleted the add-substitute-event branch April 11, 2024 11:31
AgaDufrat added a commit to alphagov/content-data-api that referenced this pull request Oct 16, 2024
It was added in alphagov/publishing-api#2664

It'll resolves the following error:
  Etl::Edition::Content::Parser::InvalidSchemaError
  Schema does not exist: substitute (Etl::Edition::Content::Parser::InvalidSchemaError)

https://govuk.sentry.io/issues/5176804130/events/7fb1eb6bf44a4e44a88a8008d5dccee9/
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.

3 participants