Skip to content

Commit

Permalink
fix: added zoneinfo and updated useragent
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomBreugelmans committed Dec 2, 2024
1 parent a03efa1 commit 65298e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions AoCH/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import re
from datetime import datetime, timedelta
from zoneinfo import ZoneInfo

import requests
from flask import Blueprint, Flask, render_template, render_template_string
Expand All @@ -22,7 +23,7 @@

# required per [community wiki](https://www.reddit.com/r/adventofcode/wiki/faqs/automation)
user_agent = (
"https://github.com/larsvantol/AoCH_Leaderboard_Frontend, t.l.breugelmans@student.tudelft.nl"
"https://github.com/WISVCH/AoCH, beheer@ch.tudelft.nl"
)
session = os.environ.get("session")
cookie = f"session={session}"
Expand Down Expand Up @@ -56,7 +57,7 @@ def current_time() -> tuple[int, int, int]:
If the current day is past Christmas, it will return 25 as the day.
"""
# Get current day
current_time = datetime.now() - timedelta(hours=6)
current_time = datetime.now(tz=ZoneInfo('Europe/Amsterdam')) - timedelta(hours=6)
this_day = current_time.day
if this_day > 25:
this_day = 25
Expand Down Expand Up @@ -147,7 +148,7 @@ def return_day_data(members, total_members, today):
for key, value in members.items():
if str(this_day) in value["completion_day_level"]:
# Today +6 hours
time_started = datetime(year=this_year, month=12, day=this_day, hour=6)
time_started = datetime(year=this_year, month=12, day=this_day, hour=6, tzinfo=ZoneInfo('Europe/Amsterdam'))

person = {
"name": value["name"],
Expand All @@ -160,7 +161,7 @@ def return_day_data(members, total_members, today):
star_time = (
datetime.fromtimestamp(
value["completion_day_level"][str(this_day)][star]["get_star_ts"]
)
, tz=ZoneInfo('Europe/Amsterdam'))
- time_started
)
else:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3-alpine as build
FROM python:3.9-alpine as build

This comment has been minimized.

Copy link
@praseodym

praseodym Dec 5, 2024

Member

Why Python 3.9? That's quite old.

This comment has been minimized.

Copy link
@ThomBreugelmans

ThomBreugelmans via email Dec 5, 2024

Author Collaborator

This comment has been minimized.

Copy link
@praseodym

praseodym Dec 5, 2024

Member

python:3-alpine currently has Python 3.13 according to https://hub.docker.com/_/python

This comment has been minimized.

Copy link
@ThomBreugelmans

ThomBreugelmans via email Dec 5, 2024

Author Collaborator
RUN pip install --upgrade pip

RUN mkdir /app
Expand Down

0 comments on commit 65298e6

Please sign in to comment.