Skip to content

AO3-7351 Deduplicate fandom tags for autocomplete#5658

Open
tommilligan wants to merge 1 commit intootwcode:masterfrom
tommilligan:AO3-7351-duplicate-tag-in-fandom
Open

AO3-7351 Deduplicate fandom tags for autocomplete#5658
tommilligan wants to merge 1 commit intootwcode:masterfrom
tommilligan:AO3-7351-duplicate-tag-in-fandom

Conversation

@tommilligan
Copy link
Contributor

Pull Request Checklist

Issue

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

Purpose

When searching for tags in multiple fandoms, the backend currently retrieves cached results from redis for each fandom, adds them together, and returns them.

If a tag is present in multiple fandoms, this means the tag is returned multiple times, and the user sees duplicate values in the autocomplete UI.

This PR deduplicates tags in the backend when searching across multiple fandoms.

Testing Instructions

There are already testing instructions in JIRA.

Note that I was not able to test this via the browser locally (I'm looking into why), but I have only confirmed the behaviour is as expected via unit tests so far (the unit test I added fails against master)

If desired, I can add end to end cucumber tests.

References

Not aware of any other relevant issues.

Credit

What name and pronouns should we use to credit you in the Archive of Our Own's Release Notes?

Tom Milligan (they/them)

Comment on lines +581 to +584
elsif fandoms.count > 1
# Fandoms may contain the same tag in cached results
# If we have multiple fandoms, deduplicate before returning
results.uniq
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was suggested in the ticket that deduplication be done on the frontend. I think it makes sense to do here and I don't see this having a massive perf impact, but wanted to call it out in case there are edge cases/concerns I'm not aware of

Copy link
Contributor

@Bilka2 Bilka2 Mar 23, 2026

Choose a reason for hiding this comment

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

Not a full review, just responding here because I wrote that part of the issue: A change like this is what was meant! The autocomplete controller calls this method, so it is indeed de-duplicating just before responding in the autocomplete controller. Another option could have been to try to change the data that's in redis, which is what we didn't want

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that makes much more sense - thanks for clarifying

Glad I got to the right place even if I couldn't read the original description 🥲

@tommilligan tommilligan force-pushed the AO3-7351-duplicate-tag-in-fandom branch from e89bb08 to 996e8a7 Compare March 23, 2026 20:59
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