Skip to content

AO3-6811 Fix tag nomination parented bug#5845

Open
pmonfort wants to merge 1 commit into
otwcode:masterfrom
pmonfort:AO3-6811
Open

AO3-6811 Fix tag nomination parented bug#5845
pmonfort wants to merge 1 commit into
otwcode:masterfrom
pmonfort:AO3-6811

Conversation

@pmonfort
Copy link
Copy Markdown
Contributor

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-6811

Purpose

When a canonical tag is saved, Tag#update_tag_nominations sets parented: true on matching TagNomination records.
However, it only checked for Fandom-type parents and only matched nominations with a blank parent_tagname (empty string).
This caused nominations to be incorrectly marked as parented: false when:

  • The tag's parent was a non-Fandom type (e.g., a Media parent on a Fandom tag).
  • The nomination had a nil parent_tagname instead of an empty string.

This PR fixes both issues by:

  1. Checking all parent types instead of only Fandoms.
  2. Including both "" and nil in the parent_names list so nominations with either blank value are matched.

Testing Instructions

  1. Create a canonical fandom tag with a Media parent (but no Fandom parent).
  2. Create a tag nomination for that fandom in a tag set.
  3. Save the fandom tag.
  4. Verify the nomination's parented field is true.

Credit

Pablo Monfort (he/him)

@sarken sarken self-requested a review June 2, 2026 03:04
@sarken
Copy link
Copy Markdown
Collaborator

sarken commented Jun 2, 2026

Assigning myself as reviewer since I saw some things I want to poke at, but I am beat so that's not gonna happen tonight

Copy link
Copy Markdown
Collaborator

@sarken sarken left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! I've updated the Jira issue with new testing steps and just have one question about this code.

Comment thread app/models/tag.rb
# Calculate the parents associated with this tag, because we'll set any
# TagNominations with a matching parent_tagname to have parented: true.
parent_names = parents.where(type: "Fandom").pluck(:name)
parent_names = parents.pluck(:name)
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'm not sure this is necessary. A nomination's parent_tagname should always be the name of a fandom unless the nominated tag itself is a fandom. For fandom nominations, it seems like the parent_tagname is always nil, never the name of a media tag. I took a look at staging to confirm:

3.4.6 :001 > noms = FandomNomination.where("parent_tagname IS NOT NULL") ; nil
 => nil 
3.4.6 :002 > noms.size
 => 0 
3.4.6 :003 > noms = FandomNomination.where(parent_tagname: "") ; nil
 => nil 
3.4.6 :004 > noms.size
 => 0 
3.4.6 :005 > noms = FandomNomination.where(parent_tagname: nil) ; nil
 => nil 
3.4.6 :006 > noms.size
 => 21488 
3.4.6 :007 > FandomNomination.all.count
 => 21488

Can you think of a scenario in which we'd expect to find a tag nomination with a non-fandom, non-blank, and non-nil parent_tagname?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants