[imports] Clean up logs and fix missing tz for birding
This commit is contained in:
@ -157,9 +157,12 @@ def import_birding_csv(file_path, user_id):
|
|||||||
|
|
||||||
stop_timestamp = timestamp + timedelta(minutes=duration_minutes) if duration_minutes else None
|
stop_timestamp = timestamp + timedelta(minutes=duration_minutes) if duration_minutes else None
|
||||||
|
|
||||||
|
tz = getattr(timestamp.tzinfo, "name", None)
|
||||||
|
|
||||||
scrobble = Scrobble(
|
scrobble = Scrobble(
|
||||||
user=user,
|
user=user,
|
||||||
timestamp=timestamp,
|
timestamp=timestamp,
|
||||||
|
timezone=tz,
|
||||||
stop_timestamp=stop_timestamp,
|
stop_timestamp=stop_timestamp,
|
||||||
source="Birding CSV Import",
|
source="Birding CSV Import",
|
||||||
birding_location=location,
|
birding_location=location,
|
||||||
|
|||||||
@ -328,12 +328,13 @@ def scan_webdav_for_bgstats(webdav_client, user_id):
|
|||||||
with open(tmp.name, "r", encoding="utf-8") as f:
|
with open(tmp.name, "r", encoding="utf-8") as f:
|
||||||
parsed_json = json.load(f)
|
parsed_json = json.load(f)
|
||||||
scrobbles = email_scrobble_board_game(parsed_json, user_id)
|
scrobbles = email_scrobble_board_game(parsed_json, user_id)
|
||||||
logger.info(
|
if scrobbles:
|
||||||
"BG Stats import from %s for user %d created %d scrobble(s)",
|
logger.info(
|
||||||
fname,
|
"BG Stats import from %s for user %d created %d scrobble(s)",
|
||||||
user_id,
|
fname,
|
||||||
len(scrobbles),
|
user_id,
|
||||||
)
|
len(scrobbles),
|
||||||
|
)
|
||||||
processed += 1
|
processed += 1
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(
|
logger.error(
|
||||||
@ -342,4 +343,4 @@ def scan_webdav_for_bgstats(webdav_client, user_id):
|
|||||||
finally:
|
finally:
|
||||||
os.unlink(tmp.name)
|
os.unlink(tmp.name)
|
||||||
|
|
||||||
return processed
|
return processed
|
||||||
|
|||||||
@ -539,9 +539,7 @@ def email_scrobble_board_game(
|
|||||||
|
|
||||||
scrobble = None
|
scrobble = None
|
||||||
if timestamp.year > 2023:
|
if timestamp.year > 2023:
|
||||||
logger.info(
|
# Scrobbles older than 2023 have play times, so try looking it up
|
||||||
"Scrobbles older than 2024 likely have no time associated just create it"
|
|
||||||
)
|
|
||||||
scrobble = Scrobble.objects.filter(
|
scrobble = Scrobble.objects.filter(
|
||||||
board_game=base_game, user_id=user_id, timestamp=timestamp
|
board_game=base_game, user_id=user_id, timestamp=timestamp
|
||||||
).first()
|
).first()
|
||||||
|
|||||||
Reference in New Issue
Block a user