Only grab fields that are needed
This commit is contained in:
@ -24,7 +24,7 @@
|
|||||||
<div class="card-body card-bottom">
|
<div class="card-body card-bottom">
|
||||||
{% for drop in campaign.drops %}
|
{% for drop in campaign.drops %}
|
||||||
<div class="col-6 col-md-4 d-flex align-items-center mb-2 position-relative">
|
<div class="col-6 col-md-4 d-flex align-items-center mb-2 position-relative">
|
||||||
<img src="{{ drop.image_url|default:'https://static-cdn.jtvnw.net/twitch-quests-assets/CAMPAIGN/default.png' }}"
|
<img src="{{ drop.image_url }}"
|
||||||
alt="{{ drop.name }} drop image"
|
alt="{{ drop.name }} drop image"
|
||||||
class="img-fluid rounded me-3"
|
class="img-fluid rounded me-3"
|
||||||
height="50"
|
height="50"
|
||||||
|
@ -85,20 +85,38 @@ def index(request: HttpRequest) -> HttpResponse:
|
|||||||
"""
|
"""
|
||||||
list_of_games: list[GameContext] = []
|
list_of_games: list[GameContext] = []
|
||||||
|
|
||||||
for game in Game.objects.all():
|
for game in Game.objects.all().only("id", "image_url", "display_name", "slug"):
|
||||||
campaigns: list[CampaignContext] = []
|
campaigns: list[CampaignContext] = []
|
||||||
for campaign in DropCampaign.objects.filter(game=game, status="ACTIVE"):
|
for campaign in DropCampaign.objects.filter(game=game, status="ACTIVE").only(
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"image_url",
|
||||||
|
"status",
|
||||||
|
"account_link_url",
|
||||||
|
"description",
|
||||||
|
"details_url",
|
||||||
|
"start_at",
|
||||||
|
"end_at",
|
||||||
|
):
|
||||||
drops: list[DropContext] = []
|
drops: list[DropContext] = []
|
||||||
|
|
||||||
drop: TimeBasedDrop
|
drop: TimeBasedDrop
|
||||||
for drop in campaign.time_based_drops.all():
|
for drop in campaign.time_based_drops.all().only(
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"required_minutes_watched",
|
||||||
|
"required_subs",
|
||||||
|
):
|
||||||
benefit: DropBenefit | None = drop.benefits.first()
|
benefit: DropBenefit | None = drop.benefits.first()
|
||||||
|
image_asset_url: str = (
|
||||||
|
benefit.image_asset_url
|
||||||
|
if benefit
|
||||||
|
else "https://static-cdn.jtvnw.net/twitch-quests-assets/CAMPAIGN/default.png"
|
||||||
|
)
|
||||||
drops.append(
|
drops.append(
|
||||||
DropContext(
|
DropContext(
|
||||||
drops_id=drop.id,
|
drops_id=drop.id,
|
||||||
image_url=benefit.image_asset_url if benefit else None,
|
image_url=image_asset_url,
|
||||||
name=drop.name,
|
name=drop.name,
|
||||||
limit=None,
|
|
||||||
required_minutes_watched=drop.required_minutes_watched,
|
required_minutes_watched=drop.required_minutes_watched,
|
||||||
required_subs=drop.required_subs,
|
required_subs=drop.required_subs,
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user