瀏覽代碼

[scrobbles] Move scrobble_log to log

Colin Powell 1 年之前
父節點
當前提交
113f200eb7

+ 18 - 0
vrobbler/apps/scrobbles/migrations/0055_rename_scrobble_log_scrobble_log.py

@@ -0,0 +1,18 @@
+# Generated by Django 4.2.11 on 2024-05-06 02:08
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("scrobbles", "0054_remove_scrobble_notes_and_more"),
+    ]
+
+    operations = [
+        migrations.RenameField(
+            model_name="scrobble",
+            old_name="scrobble_log",
+            new_name="log",
+        ),
+    ]

+ 4 - 4
vrobbler/apps/scrobbles/models.py

@@ -521,7 +521,7 @@ class Scrobble(TimeStampedModel):
 
     # Metadata
     source = models.CharField(max_length=255, **BNULL)
-    scrobble_log = models.JSONField(**BNULL)
+    log = models.JSONField(**BNULL)
     timezone = models.CharField(max_length=50, **BNULL)
 
     # Fields for keeping track of book data
@@ -992,10 +992,10 @@ class Scrobble(TimeStampedModel):
 
         if existing_locations := location.in_proximity(named=True):
             existing_location = existing_locations.first()
-            scrobble.scrobble_log[
+            scrobble.log[
                 pendulum.now().timestamp
             ] = f"Location {location.id} too close to this scrobble"
-            scrobble.save(update_fields=["scrobble_log"])
+            scrobble.save(update_fields=["log"])
             logger.info(
                 f"[scrobbling] finished - found existing named location",
                 extra={
@@ -1074,7 +1074,7 @@ class Scrobble(TimeStampedModel):
         cls,
         scrobble_data: dict,
     ) -> "Scrobble":
-        scrobble_data["scrobble_log"] = {}
+        scrobble_data["log"] = {}
         scrobble = cls.objects.create(
             **scrobble_data,
         )

+ 3 - 4
vrobbler/apps/scrobbles/scrobblers.py

@@ -141,7 +141,7 @@ def build_scrobble_dict(data_dict: dict, user_id: int) -> dict:
         "timestamp": parse(data_dict.get("UtcTimestamp")),
         "playback_position_seconds": playback_seconds,
         "source": data_dict.get("ClientName", "Vrobbler"),
-        "scrobble_log": {"media_source_id": data_dict.get("MediaSourceId")},
+        "log": {"media_source_id": data_dict.get("MediaSourceId")},
         "jellyfin_status": jellyfin_status,
     }
 
@@ -362,8 +362,7 @@ def gpslogger_scrobble_location(data_dict: dict, user_id: int) -> Scrobble:
 
     provider = LOCATION_PROVIDERS[data_dict.get("prov")]
 
-    scrobble.scrobble_log["update"] = {
-        "timestamp": data_dict.get("time"),
+    scrobble.log[data_dict.get("time")] = {
         "position_provider": provider,
     }
     if scrobble.timestamp:
@@ -371,7 +370,7 @@ def gpslogger_scrobble_location(data_dict: dict, user_id: int) -> Scrobble:
             timezone.now() - scrobble.timestamp
         ).seconds
 
-    scrobble.save(update_fields=["scrobble_log", "playback_position_seconds"])
+    scrobble.save(update_fields=["log", "playback_position_seconds"])
     logger.info(
         "[webhook] gpslogger scrobble request received",
         extra={

+ 1 - 1
vrobbler/apps/scrobbles/tsv.py

@@ -75,7 +75,7 @@ def process_audioscrobbler_tsv_file(file_path, user_id, user_tz=None):
             user_id=user_id,
             timestamp=timestamp,
             source=source,
-            scrobble_log={"rockbox_info": rockbox_info}
+            log={"rockbox_info": rockbox_info}
             track=track,
             played_to_completion=True,
             in_progress=False,