Skip to content

Commit

Permalink
Fix spurious agent duplication bug
Browse files Browse the repository at this point in the history
  • Loading branch information
XanderVertegaal committed Dec 9, 2024
1 parent 2d15266 commit 9fcc99c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/event/types/EpisodeType.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@

from event.models import Episode, EpisodeCategory
from event.types.EpisodeCategoryType import EpisodeCategoryType
from person.models import AgentDescription


class EpisodeType(EntityDescriptionType, DjangoObjectType):
categories = List(NonNull(EpisodeCategoryType), required=True)
agents = List(
NonNull("person.types.AgentDescriptionType.AgentDescriptionType"), required=True
)

class Meta:
model = Episode
Expand All @@ -17,7 +21,6 @@ class Meta:
"summary",
"categories",
"designators",
"agents",
"gifts",
"letters",
"spaces",
Expand All @@ -32,6 +35,14 @@ def get_queryset(
) -> QuerySet[Episode]:
return queryset.all()

@staticmethod
def resolve_agents(
parent: Episode, info: ResolveInfo
) -> QuerySet[AgentDescription]:
# Without distinct(), this returns one agent for every HistoricalPerson linked
# to that agent, for some reason.
return parent.agents.distinct()

@staticmethod
def resolve_categories(
parent: Episode, info: ResolveInfo
Expand Down

0 comments on commit 9fcc99c

Please sign in to comment.