From 5433e1d9ce7221d960bc1c6415b3dc7603d0580a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Mon, 22 Jul 2024 16:56:19 +0200 Subject: [PATCH] Fix small things --- config/settings.py | 18 +++++++++--------- core/templates/partials/game_card.html | 8 ++++---- .../management/commands/scrape_twitch.py | 7 +++++-- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/config/settings.py b/config/settings.py index 56c3a32..0d6f219 100644 --- a/config/settings.py +++ b/config/settings.py @@ -19,13 +19,14 @@ DATA_DIR = Path( DEBUG: bool = os.getenv(key="DEBUG", default="True").lower() == "true" -sentry_sdk.init( - dsn="https://35519536b56710e51cac49522b2cc29f@o4505228040339456.ingest.sentry.io/4506447308914688", - environment="Development" if DEBUG else "Production", - send_default_pii=True, - traces_sample_rate=0.2, - profiles_sample_rate=0.2, -) +if not DEBUG: + sentry_sdk.init( + dsn="https://35519536b56710e51cac49522b2cc29f@o4505228040339456.ingest.sentry.io/4506447308914688", + environment="Production", + send_default_pii=True, + traces_sample_rate=0.2, + profiles_sample_rate=0.2, + ) BASE_DIR: Path = Path(__file__).resolve().parent.parent ADMINS: list[tuple[str, str]] = [("Joakim Hellsén", "tlovinator@gmail.com")] @@ -46,9 +47,8 @@ STATIC_ROOT.mkdir(exist_ok=True) if DEBUG: INTERNAL_IPS: list[str] = ["127.0.0.1"] - if not DEBUG: - ALLOWED_HOSTS: list[str] = ["ttvdrops.lovinator.space"] + ALLOWED_HOSTS: list[str] = ["ttvdrops.lovinator.space", "localhost"] EMAIL_HOST = "smtp.gmail.com" EMAIL_PORT = 587 diff --git a/core/templates/partials/game_card.html b/core/templates/partials/game_card.html index 2646a8b..1a27e2b 100644 --- a/core/templates/partials/game_card.html +++ b/core/templates/partials/game_card.html @@ -33,7 +33,7 @@ {% endfor %} - {% for campaign in game.campaigns %} + {% for campaign in game.drop_campaigns.all %} {% if not forloop.first %}
{% endif %}

{{ campaign.name }}

@@ -61,15 +61,15 @@ {% endif %} {% endif %}
- {% for drop in campaign.drops %} + {% for drop in campaign.drops.all %}
- {{ drop.name }} drop image - {{ drop.name }} + {{ drop.name }} - {{ drop.required_minutes_watched }}
{% endfor %}
diff --git a/twitch_app/management/commands/scrape_twitch.py b/twitch_app/management/commands/scrape_twitch.py index a75719a..26774c3 100644 --- a/twitch_app/management/commands/scrape_twitch.py +++ b/twitch_app/management/commands/scrape_twitch.py @@ -144,14 +144,14 @@ async def insert_data(data: dict) -> None: # noqa: C901, PLR0914 "image_asset_url": benefit_data.get("imageAssetURL"), "is_ios_available": benefit_data.get("isIosAvailable"), "name": benefit_data.get("name"), - "owner_organization": org, - "game": benefit_game, }, ) if created: logger.debug("Drop created: %s", drop) + await sync_to_async(drop.save)() + class Command(BaseCommand): help = "Scrape Twitch Drops Campaigns with login using Firefox" @@ -227,6 +227,9 @@ class Command(BaseCommand): continue if "dropCampaign" in campaign.get("data", {}).get("user", {}): + if not campaign["data"]["user"]["dropCampaign"]: + continue + await insert_data(campaign) if "dropCampaigns" in campaign.get("data", {}).get("user", {}):