Skip to content

Commit

Permalink
Remove tags_list from models and ingestion_server (#956)
Browse files Browse the repository at this point in the history
* Remove `tags_list` from models and ingestion_server

* Add migration

* Remove the `defer` code for non-existent field
  • Loading branch information
obulat authored Apr 27, 2023
1 parent cfc9e98 commit 7141049
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 32 deletions.
21 changes: 21 additions & 0 deletions api/catalog/api/migrations/0053_remove_tags_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.1.7 on 2023-03-22 16:20

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('api', '0052_relational_fields'),
]

operations = [
migrations.RemoveField(
model_name='audio',
name='tags_list',
),
migrations.RemoveField(
model_name='image',
name='tags_list',
),
]
27 changes: 0 additions & 27 deletions api/catalog/api/models/media.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import mimetypes

from django.conf import settings
from django.contrib.postgres.fields import ArrayField
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.html import format_html
Expand All @@ -26,24 +25,6 @@
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 @@ -89,12 +70,6 @@ class AbstractMedia(
null=True,
help_text="Tags with detailed metadata, such as accuracy.",
)
tags_list = ArrayField(
base_field=models.CharField(max_length=255),
blank=True,
null=True,
help_text="List of tags names without detailed metadata.",
)

category = models.CharField(
max_length=80,
Expand All @@ -106,8 +81,6 @@ 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
1 change: 0 additions & 1 deletion ingestion_server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ class Image(SyncableDocType):
identifier=row[schema['identifier']],
creator=row[schema['creator']],
creator_url=row[schema['creator_url']],
tags=row[schema['tags_list']],
created_on=row[schema['created_on']],
url=row[schema['url']],
thumbnail=row[schema['thumbnail']],
Expand Down
1 change: 0 additions & 1 deletion ingestion_server/test/mock_schemas/audio.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ CREATE TABLE public.audio (
removed_from_source boolean NOT NULL,
view_count integer,
tags jsonb,
tags_list character varying(255)[],
meta_data jsonb,
audio_set_position integer,
genres character varying(80)[],
Expand Down
1 change: 0 additions & 1 deletion ingestion_server/test/mock_schemas/audio_view.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ CREATE TABLE public.audio_view (
removed_from_source boolean NOT NULL,
view_count integer,
tags jsonb,
tags_list character varying(255)[],
meta_data jsonb,
audio_set_position integer,
genres character varying(80)[],
Expand Down
1 change: 0 additions & 1 deletion ingestion_server/test/mock_schemas/image.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ CREATE TABLE public.image (
creator character varying(2000),
creator_url character varying(2000),
title character varying(5000),
tags_list character varying(255)[],
last_synced_with_source timestamp with time zone,
removed_from_source boolean NOT NULL,
meta_data jsonb,
Expand Down
1 change: 0 additions & 1 deletion ingestion_server/test/mock_schemas/image_view.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ CREATE TABLE public.image_view (
creator character varying(2000),
creator_url character varying(2000),
title character varying(2000),
tags_list character varying(255)[],
last_synced_with_source timestamp with time zone,
removed_from_source boolean NOT NULL,
meta_data jsonb,
Expand Down

0 comments on commit 7141049

Please sign in to comment.