Skip to content

Commit

Permalink
Defer the tags_list for media models (#1029)
Browse files Browse the repository at this point in the history
* Defer the `tags_list` for media models

* Update api/catalog/api/models/media.py

Co-authored-by: Madison Swain-Bowden <[email protected]>

* Rename manager to TagsListDeferralManager

---------

Co-authored-by: Madison Swain-Bowden <[email protected]>
  • Loading branch information
obulat and AetherUnbound authored Mar 28, 2023
1 parent 2ca2f15 commit b33c91d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions api/catalog/api/models/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@
OTHER = "other"


class TagsListDeferralManager(models.Manager):
"""
Custom manager used temporarily to enable zero-downtime removal of the deprecated
`tags_list` field from the media modals.
@see https://github.com/WordPress/openverse/pull/956.
"""

def get_queryset(self):
return (
super()
.get_queryset()
.defer(
"tags_list",
)
)


class AbstractMedia(
IdentifierMixin, ForeignIdentifierMixin, MediaMixin, OpenLedgerModel
):
Expand Down Expand Up @@ -88,6 +106,8 @@ class AbstractMedia(

meta_data = models.JSONField(blank=True, null=True)

objects = TagsListDeferralManager()

@property
def license_url(self) -> str:
"""A direct link to the license deed or legal terms."""
Expand Down

0 comments on commit b33c91d

Please sign in to comment.