Skip to content

Commit 1652933

Browse files
committed
Only migrate to tags on open commitfests
1 parent 33d014a commit 1652933

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

pgcommitfest/commitfest/migrations/0016_migrate_topics_to_tags.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@
55

66
def create_missing_tags_and_map_topics(apps, schema_editor):
77
"""
8-
Create missing tags and map existing topics to appropriate tags
8+
Create missing tags and map existing topics to appropriate tags.
9+
Only applies to patches in active (open or in-progress) commitfests.
910
"""
1011
Tag = apps.get_model("commitfest", "Tag")
1112
Patch = apps.get_model("commitfest", "Patch")
1213
Topic = apps.get_model("commitfest", "Topic")
14+
PatchOnCommitFest = apps.get_model("commitfest", "PatchOnCommitFest")
15+
16+
# CommitFest status constants (matching models.py)
17+
STATUS_OPEN = 2
18+
STATUS_INPROGRESS = 3
1319

1420
# Create missing tags
1521
Tag.objects.get_or_create(
@@ -46,14 +52,23 @@ def create_missing_tags_and_map_topics(apps, schema_editor):
4652
# 'Miscellaneous' and 'Server Features' are left untagged
4753
}
4854

55+
# Get patch IDs that are in active commitfests (open or in-progress)
56+
active_patch_ids = set(
57+
PatchOnCommitFest.objects.filter(
58+
commitfest__status__in=[STATUS_OPEN, STATUS_INPROGRESS]
59+
).values_list("patch_id", flat=True)
60+
)
61+
4962
# Apply tags to existing patches based on their topics
5063
for topic_name, tag_name in topic_tag_mapping.items():
5164
try:
5265
topic = Topic.objects.get(topic=topic_name)
5366
tag = Tag.objects.get(name=tag_name)
5467

55-
# Get all patches with this topic
56-
patches_with_topic = Patch.objects.filter(topic=topic)
68+
# Get patches with this topic that are in active commitfests
69+
patches_with_topic = Patch.objects.filter(
70+
topic=topic, id__in=active_patch_ids
71+
)
5772

5873
# Add the corresponding tag to each patch
5974
for patch in patches_with_topic:

0 commit comments

Comments
 (0)