Skip to content

Conversation

@eviljeff
Copy link
Member

@eviljeff eviljeff commented Dec 9, 2025

Fixes: mozilla/addons#15957

Description

Removes the PromotedClass constants, that defined the properties of promoted groups.

Context

Most places that referenced the constants could be rewritten to use PROMOTED_GROUP_CHOICES instead, but that does mean if we eventually want to allow new promoted groups to be defined dynamically (i.e. delete PROMOTED_GROUP_CHOICES too), we're left with a lot of code that needs updating to make database queries instead. (search filters that rely only on publicly exposed classes would probably still use some constants).

On the other hand, if we're happy with constants defining the fixed list of groups available, along with their names and api_names, then we have duplicated data - we don't want the group name/api_name defined both in constants and in the database, ideally. (And that api_name is api_value in APIChoices is annoyingly different too)

I vendored in the old constants to make the old migration still work. Could have been removed instead, but then we'd kind of need fixtures that define the expected promoted groups instead.

Testing

Everything should really be covered by existing tests, but anything that might touch promoted groups could be manually tested. In particular (based on the code I had to touch):

  • api search results for promoted add-ons
  • search filters - e.g. you can filter by the different promoted groups and badged
  • you can only add certain add-ons in promoted groups to the primary hero shelves (based on the groups can_primary_hero property)

Checklist

  • Add #ISSUENUM at the top of your PR to an existing open issue in the mozilla/addons repository.
  • Successfully verified the change locally.
  • The change is covered by automated tests, or otherwise indicated why doing so is unnecessary/impossible.
  • Add before and after screenshots (Only for changes that impact the UI).
  • Add or update relevant docs reflecting the changes made.
@eviljeff eviljeff force-pushed the 15957-rm-old-promoted-classes branch 5 times, most recently from d87006e to 75f0da9 Compare December 10, 2025 12:38
@eviljeff eviljeff force-pushed the 15957-rm-old-promoted-classes branch from 75f0da9 to cb45b45 Compare December 10, 2025 13:12
@eviljeff eviljeff marked this pull request as ready for review December 10, 2025 13:13
@eviljeff eviljeff requested a review from diox December 10, 2025 13:13
Copy link
Member

@diox diox left a comment

Choose a reason for hiding this comment

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

Some thoughts to put on on the path to getting rid of some of the duplication between code and database. Could be done in a follow-up if you prefer ? Let me know.

@eviljeff eviljeff force-pushed the 15957-rm-old-promoted-classes branch from 6b88601 to 4f07909 Compare December 12, 2025 12:21
@eviljeff eviljeff requested a review from diox December 12, 2025 12:38
@eviljeff eviljeff merged commit 8d406e0 into mozilla:master Dec 15, 2025
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants