Skip to content

Commit 00b4614

Browse files
committed
indexes added
1 parent fc59e43 commit 00b4614

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Generated by Django 5.2.9 on 2025-12-12 13:58
2+
3+
from django.conf import settings
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
dependencies = [
9+
("website", "0261_add_connected_action_type"),
10+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
11+
]
12+
13+
operations = [
14+
migrations.RenameIndex(
15+
model_name="socialaccountreward",
16+
new_name="website_soc_user_id_fb0840_idx",
17+
old_name="website_soc_user_id_provid_idx",
18+
),
19+
migrations.AddIndex(
20+
model_name="githubissue",
21+
index=models.Index(fields=["type", "is_merged", "merged_at"], name="githubissue_pr_merged_idx"),
22+
),
23+
migrations.AddIndex(
24+
model_name="githubissue",
25+
index=models.Index(fields=["merged_at"], name="githubissue_merged_date_idx"),
26+
),
27+
]

website/models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,6 +2158,18 @@ class GitHubIssue(models.Model):
21582158
class Meta:
21592159
# Make the combination of issue_id and repo unique
21602160
unique_together = ("issue_id", "repo")
2161+
indexes = [
2162+
# Composite index for GSOC PR report queries
2163+
models.Index(
2164+
fields=["type", "is_merged", "merged_at"],
2165+
name="githubissue_pr_merged_idx",
2166+
),
2167+
# Additional index for date range queries
2168+
models.Index(
2169+
fields=["merged_at"],
2170+
name="githubissue_merged_date_idx",
2171+
),
2172+
]
21612173

21622174
def __str__(self):
21632175
return f"{self.title} by {self.user_profile.user.username if self.user_profile else 'Unknown'} - {self.state}"

website/views/project.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2210,7 +2210,8 @@ def gsoc_pr_report(request):
22102210
end_date = timezone.make_aware(datetime(year, 10, 1))
22112211

22122212
repos_qs = (
2213-
GitHubIssue.objects.filter(
2213+
GitHubIssue.objects.select_related("repo", "contributor")
2214+
.filter(
22142215
type="pull_request",
22152216
is_merged=True,
22162217
merged_at__gte=start_date,

0 commit comments

Comments
 (0)