Skip to content

[WHIT-3125] Filter by latest edition of document#11203

Open
GDSNewt wants to merge 1 commit intomainfrom
stop-surfacing-duplicate-topical-events-in-dropdown
Open

[WHIT-3125] Filter by latest edition of document#11203
GDSNewt wants to merge 1 commit intomainfrom
stop-surfacing-duplicate-topical-events-in-dropdown

Conversation

@GDSNewt
Copy link
Contributor

@GDSNewt GDSNewt commented Mar 4, 2026

ISSUE

Creating a new edition of an existing config-driven topical event causes an additional entry to appear in the associations dropdown.

BEFORE

Screenshot 2026-03-03 at 09 36 48

AFTER


Screenshot 2026-03-11 at 15 58 32

The 'first test event' example is the second edition of that document, the 'other topical event' is another document

THIS PR

We should only display one option. This is a code change to filter out all but the latest edition of a document.

Jira

@GDSNewt GDSNewt changed the title Filter by latest edition of document [WHIT-3125] Filter by latest edition of document Mar 4, 2026
Copy link
Contributor

@ryanb-gds ryanb-gds left a comment

Choose a reason for hiding this comment

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

Just wanna check something but pretty sure this'll solve the problem 🙌

@GDSNewt GDSNewt force-pushed the stop-surfacing-duplicate-topical-events-in-dropdown branch from a0559e3 to 83060ea Compare March 4, 2026 16:59
Copy link
Contributor

@ryanb-gds ryanb-gds left a comment

Choose a reason for hiding this comment

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

One small correction

@GDSNewt GDSNewt requested a review from ryanb-gds March 10, 2026 15:06
@GDSNewt GDSNewt force-pushed the stop-surfacing-duplicate-topical-events-in-dropdown branch from 83060ea to 3be5c0a Compare March 10, 2026 15:16
@GDSNewt GDSNewt force-pushed the stop-surfacing-duplicate-topical-events-in-dropdown branch 2 times, most recently from fdd887e to 43aa8e3 Compare March 11, 2026 15:55
@GDSNewt GDSNewt force-pushed the stop-surfacing-duplicate-topical-events-in-dropdown branch from 43aa8e3 to a1b8eb5 Compare March 11, 2026 16:02
Comment on lines +10 to +16
def topical_event_documents
Document
.joins(latest_edition: :translations)
.where(editions: { configurable_document_type: "topical_event" })
.preload(latest_edition: :translations)
.order("edition_translations.title")
end
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit misleading for a test. All we're doing is writing some code in this test file, and testing that code - there's no guarantee we're running the same code inside app/views/admin/editions/_topical_event_fields.html.erb.

The correct way to do this would be to move the code from the view, into a helper (or as a scope/helper method on the Edition::TopicalEvents concern) so that we can write tests against the actual code that is being used.

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