[scrobbles] Fix bug in migrate script and update logging

This commit is contained in:
2024-04-05 12:00:51 -04:00
parent 1dcd151c65
commit a0c414135c
2 changed files with 5 additions and 6 deletions

View File

@ -39,7 +39,7 @@ class Command(BaseCommand):
updated_scrobble_count += 1 updated_scrobble_count += 1
if not dry_run: if not dry_run:
scrobble.save(update_fields="scrobble_log") scrobble.save(update_fields=["scrobble_log"])
else: else:
print( print(
f"Scrobble {scrobble} scrobble_log updated to {old_data}" f"Scrobble {scrobble} scrobble_log updated to {old_data}"

View File

@ -960,10 +960,9 @@ class Scrobble(TimeStampedModel):
if existing_locations := location.in_proximity(named=True): if existing_locations := location.in_proximity(named=True):
existing_location = existing_locations.first() existing_location = existing_locations.first()
scrobble.scrobble_log = ( scrobble.scrobble_log[
scrobble.scrobble_log pendulum.now.timestamp
+ "\nLocation {location.id} too close to this scrobble" ] = f"Location {location.id} too close to this scrobble"
)
scrobble.save(update_fields=["scrobble_log"]) scrobble.save(update_fields=["scrobble_log"])
logger.info( logger.info(
f"[scrobbling] finished - found existing named location", f"[scrobbling] finished - found existing named location",
@ -1051,7 +1050,7 @@ class Scrobble(TimeStampedModel):
cls, cls,
scrobble_data: dict, scrobble_data: dict,
) -> "Scrobble": ) -> "Scrobble":
scrobble_data["scrobble_log"] = "" scrobble_data["scrobble_log"] = {}
scrobble = cls.objects.create( scrobble = cls.objects.create(
**scrobble_data, **scrobble_data,
) )