Skip to content

Commit

Permalink
Update UXActionLog records (mozilla#3283)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayanaar authored Jul 26, 2024
1 parent 6db8a16 commit 2d5872e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pontoon/uxactionlog/migrations/0002_update_locale_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 4.2.11 on 2024-07-24 18:49

from django.db import migrations


def update_locale_code(apps, schema_editor):
UXActionLog = apps.get_model("uxactionlog", "UXActionLog")
Locale = apps.get_model("base", "Locale")

for log in UXActionLog.objects.filter(action_type="LLM Dropdown Select"):
data = log.data
if "targetLanguage" in data:
locale_name = data.pop("targetLanguage")
locale = Locale.objects.filter(name=locale_name).first()
data["localeCode"] = locale.code
log.data = data
log.save()


class Migration(migrations.Migration):
dependencies = [
("uxactionlog", "0001_initial"),
(
"base",
"0001_squashed_0154_auto_20200206_1736",
), # Ensure the Locale model's migration is applied first
]

operations = [
migrations.RunPython(
code=update_locale_code,
reverse_code=migrations.RunPython.noop,
),
]

0 comments on commit 2d5872e

Please sign in to comment.