Improve sitemaps
All checks were successful
Deploy to Server / deploy (push) Successful in 9s

This commit is contained in:
Joakim Hellsén 2026-02-27 06:02:30 +01:00
commit 415dd12fd9
Signed by: Joakim Hellsén
SSH key fingerprint: SHA256:/9h/CsExpFp+PRhsfA0xznFx2CGfTT5R/kpuFfUgEQk
16 changed files with 843 additions and 379 deletions

View file

@ -159,11 +159,11 @@ class RSSFeedTestCase(TestCase):
def test_organization_campaign_feed_filters_correctly(self) -> None:
"""Test organization campaign feed only shows campaigns for that organization."""
# Create another organization with a game and campaign
other_org = Organization.objects.create(
other_org: Organization = Organization.objects.create(
twitch_id="other-org-123",
name="Other Organization",
)
other_game = Game.objects.create(
other_game: Game = Game.objects.create(
twitch_id="other-game-456",
slug="other-game-2",
name="Other Game 2",
@ -299,21 +299,48 @@ def test_campaign_feed_queries_do_not_scale_with_items(
)
game.owners.add(org)
campaigns: list[DropCampaign] = []
channels: list[Channel] = []
benefits: list[DropBenefit] = []
for i in range(50):
campaign: DropCampaign = DropCampaign.objects.create(
twitch_id=f"scale-campaign-{i}",
name=f"Scale Campaign {i}",
game=game,
start_at=timezone.now(),
end_at=timezone.now() + timedelta(days=7),
operation_names=["DropCampaignDetails"],
campaigns.append(
DropCampaign(
twitch_id=f"scale-campaign-{i}",
name=f"Scale Campaign {i}",
game=game,
start_at=timezone.now(),
end_at=timezone.now() + timedelta(days=7),
operation_names=["DropCampaignDetails"],
),
)
channel: Channel = Channel.objects.create(
twitch_id=f"scale-channel-{i}",
name=f"scalechannel{i}",
display_name=f"ScaleChannel{i}",
channels.append(
Channel(
twitch_id=f"scale-channel-{i}",
name=f"scalechannel{i}",
display_name=f"ScaleChannel{i}",
),
)
campaign.allow_channels.add(channel)
benefits.append(
DropBenefit(
twitch_id=f"scale-benefit-{i}",
name=f"Scale Benefit {i}",
distribution_type="ITEM",
),
)
DropCampaign.objects.bulk_create(campaigns)
Channel.objects.bulk_create(channels)
DropBenefit.objects.bulk_create(benefits)
assert len(DropCampaign.objects.all()) == 50
assert len(Channel.objects.all()) == 50
assert len(DropBenefit.objects.all()) == 50
channels_by_id: dict[str, Channel] = {c.twitch_id: c for c in channels}
benefits_by_id: dict[str, DropBenefit] = {b.twitch_id: b for b in benefits}
for i, campaign in enumerate(campaigns):
drop: TimeBasedDrop = TimeBasedDrop.objects.create(
twitch_id=f"scale-drop-{i}",
name=f"Scale Drop {i}",
@ -322,12 +349,8 @@ def test_campaign_feed_queries_do_not_scale_with_items(
start_at=timezone.now(),
end_at=timezone.now() + timedelta(hours=1),
)
benefit: DropBenefit = DropBenefit.objects.create(
twitch_id=f"scale-benefit-{i}",
name=f"Scale Benefit {i}",
distribution_type="ITEM",
)
drop.benefits.add(benefit)
campaign.allow_channels.add(channels_by_id[f"scale-channel-{i}"])
drop.benefits.add(benefits_by_id[f"scale-benefit-{i}"])
url: str = reverse("twitch:campaign_feed")