-
-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Both the async and sync installation_repositories event handlers have an N+1 query pattern when checking for existing repositories:
# In async_installation_repositories (src/django_github_app/events/ainstallation.py)
added = [
Repository(
installation=await Installation.objects.aget_from_event(event),
repository_id=repo["id"],
repository_node_id=repo["node_id"],
full_name=repo["full_name"],
)
for repo in event.data["repositories_added"]
# here
if not await Repository.objects.filter(repository_id=repo["id"]).aexists()
]
# In sync_installation_repositories (src/django_github_app/events/installation.py)
added = [
Repository(
installation=Installation.objects.get_from_event(event),
repository_id=repo["id"],
repository_node_id=repo["node_id"],
full_name=repo["full_name"],
)
for repo in event.data["repositories_added"]
# and here
if not Repository.objects.filter(repository_id=repo["id"]).exists()
]
Metadata
Metadata
Assignees
Labels
No labels