# Generated by Django 4.2.7 on 2024-02-08 09:57 from django.db import migrations def widgets_filter_change(apps, schema_editor): Widget = apps.get_model("db", "Widget") widgets_to_update = [] # Define the filter dictionaries for each widget key filters_mapping = { "assigned_issues": {"duration": "none", "tab": "pending"}, "created_issues": {"duration": "none", "tab": "pending"}, "issues_by_state_groups": {"duration": "none"}, "issues_by_priority": {"duration": "none"}, } # Iterate over widgets and update filters if applicable for widget in Widget.objects.all(): if widget.key in filters_mapping: widget.filters = filters_mapping[widget.key] widgets_to_update.append(widget) # Bulk update the widgets Widget.objects.bulk_update(widgets_to_update, ["filters"], batch_size=10) class Migration(migrations.Migration): dependencies = [ ("db", "0058_alter_moduleissue_issue_and_more"), ] operations = [migrations.RunPython(widgets_filter_change)]