# Generated by Django 3.1.7 on 2021-03-02 18:37

from django.db import migrations

from search.utils import get_querystring_programs


def populate_aidsearchevent_programs(apps, schema_editor):
    AidSearchEvent = apps.get_model("stats", "AidSearchEvent")
    for event in AidSearchEvent.objects.all():
        event_programs = get_querystring_programs(event.querystring)
        event_programs_id_list = [program.id for program in event_programs]
        event.programs.set(event_programs_id_list)


class Migration(migrations.Migration):

    dependencies = [
        ("stats", "0013_aidsearchevent_programs"),
    ]

    operations = [migrations.RunPython(populate_aidsearchevent_programs)]
