From a0c414135c23f0db576dc1b64c74a08b38354599 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Fri, 5 Apr 2024 12:00:51 -0400 Subject: [PATCH] [scrobbles] Fix bug in migrate script and update logging --- .../management/commands/migrate_scrobble_log_to_json.py | 2 +- vrobbler/apps/scrobbles/models.py | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/vrobbler/apps/scrobbles/management/commands/migrate_scrobble_log_to_json.py b/vrobbler/apps/scrobbles/management/commands/migrate_scrobble_log_to_json.py index bf36391..c3e05fd 100644 --- a/vrobbler/apps/scrobbles/management/commands/migrate_scrobble_log_to_json.py +++ b/vrobbler/apps/scrobbles/management/commands/migrate_scrobble_log_to_json.py @@ -39,7 +39,7 @@ class Command(BaseCommand): updated_scrobble_count += 1 if not dry_run: - scrobble.save(update_fields="scrobble_log") + scrobble.save(update_fields=["scrobble_log"]) else: print( f"Scrobble {scrobble} scrobble_log updated to {old_data}" diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.py index 42ab33b..3227eb4 100644 --- a/vrobbler/apps/scrobbles/models.py +++ b/vrobbler/apps/scrobbles/models.py @@ -960,10 +960,9 @@ class Scrobble(TimeStampedModel): if existing_locations := location.in_proximity(named=True): existing_location = existing_locations.first() - scrobble.scrobble_log = ( - scrobble.scrobble_log - + "\nLocation {location.id} too close to this scrobble" - ) + scrobble.scrobble_log[ + pendulum.now.timestamp + ] = f"Location {location.id} too close to this scrobble" scrobble.save(update_fields=["scrobble_log"]) logger.info( f"[scrobbling] finished - found existing named location", @@ -1051,7 +1050,7 @@ class Scrobble(TimeStampedModel): cls, scrobble_data: dict, ) -> "Scrobble": - scrobble_data["scrobble_log"] = "" + scrobble_data["scrobble_log"] = {} scrobble = cls.objects.create( **scrobble_data, )