Fix remaining time

This commit is contained in:
2024-08-21 05:48:54 +02:00
parent 2c70897647
commit 426a499300
4 changed files with 12 additions and 5 deletions

View File

@ -74,10 +74,16 @@ def get_games_with_drops() -> BaseManager[Game]:
# Prefetch Benefits for each TimeBasedDrop
benefits_prefetch = Prefetch(lookup="benefits", queryset=Benefit.objects.all())
# Filter active time-based drops
active_time_based_drops: BaseManager[TimeBasedDrop] = TimeBasedDrop.objects.filter(ends_at__gte=timezone.now())
# Prefetch Benefits for each active TimeBasedDrop
benefits_prefetch = Prefetch(lookup="benefits", queryset=Benefit.objects.all())
# Prefetch TimeBasedDrops for each DropCampaign and include the prefetch of Benefits
time_based_drops_prefetch = Prefetch(
lookup="drops",
queryset=TimeBasedDrop.objects.prefetch_related(benefits_prefetch),
queryset=active_time_based_drops.prefetch_related(benefits_prefetch),
)
# Prefetch DropCampaigns for each Game and include the prefetch of TimeBasedDrops