diff --git a/app/grants/migrations/0133_auto_20211214_1413.py b/app/grants/migrations/0133_auto_20211214_1413.py new file mode 100644 index 00000000000..859b7b8448e --- /dev/null +++ b/app/grants/migrations/0133_auto_20211214_1413.py @@ -0,0 +1,17 @@ +# Generated by Django 2.2.24 on 2021-12-14 14:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('grants', '0132_auto_20211203_1427'), + ] + + operations = [ + migrations.AddIndex( + model_name='subscription', + index=models.Index(fields=['contributor_address'], name='grants_subs_contrib_d72508_idx'), + ), + ] diff --git a/app/grants/models/subscription.py b/app/grants/models/subscription.py index ff17a252267..d2a031e0ca6 100644 --- a/app/grants/models/subscription.py +++ b/app/grants/models/subscription.py @@ -617,3 +617,8 @@ def create_contribution(self, tx_id, is_successful_contribution=True): update_grant_metadata.delay(self.pk) return contribution + + class Meta: + indexes = [ + models.Index(fields=['contributor_address',]), + ] \ No newline at end of file diff --git a/app/grants/views.py b/app/grants/views.py index f4eb2b4ecb7..d43e9f5dd5d 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -3752,11 +3752,7 @@ def get_trust_bonus(request): except: return allow_all_origins(HttpResponse(status=400)) - query = Q() - for address in addresses: - query |= Q(contributor_address=address) - - subscriptions = Subscription.objects.filter(query).prefetch_related('contributor_profile') + subscriptions = Subscription.objects.filter(contributor_address__in=addresses).prefetch_related('contributor_profile') response = [] _addrs = [] for subscription in subscriptions: