From 89d53a15c92d4c6f357c08e2e41f17ce6f93ec9f Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Thu, 27 Feb 2025 16:21:29 +0100 Subject: [PATCH] digest_tags: just use project_id to avoid lookups maybe maybe the passed-in event also avoids this, but the present method will always do what you expect and this is obvious upon reading, rather than have the reader think about something --- tags/models.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tags/models.py b/tags/models.py index 2d01510..b9d6b73 100644 --- a/tags/models.py +++ b/tags/models.py @@ -96,8 +96,7 @@ def digest_tags(event_data, event, issue): value = value[:200] # TODO just use bulk_create for each of the types of objects - # TODO check: event.project won't trigger a query, right? it's already loaded, right? - tag_key, _ = TagKey.objects.get_or_create(project=event.project, key=key) - tag_value, _ = TagValue.objects.get_or_create(project=event.project, key=tag_key, value=value) - EventTag.objects.get_or_create(project=event.project, value=tag_value, event=event) - IssueTag.objects.get_or_create(project=event.project, value=tag_value, issue=issue) + tag_key, _ = TagKey.objects.get_or_create(project_id=event.project_id, key=key) + tag_value, _ = TagValue.objects.get_or_create(project_id=event.project_id, key=tag_key, value=value) + EventTag.objects.get_or_create(project_id=event.project_id, value=tag_value, event=event) + IssueTag.objects.get_or_create(project_id=event.project_id, value=tag_value, issue=issue)