瀏覽代碼

Use constant for location providers

Colin Powell 1 年之前
父節點
當前提交
f18d81296b
共有 2 個文件被更改,包括 10 次插入1 次删除
  1. 7 0
      vrobbler/apps/locations/constants.py
  2. 3 1
      vrobbler/apps/scrobbles/scrobblers.py

+ 7 - 0
vrobbler/apps/locations/constants.py

@@ -0,0 +1,7 @@
+#!/usr/bin/env python3
+from collections import defaultdict
+
+
+LOCATION_PROVIDERS = defaultdict(lambda: "Unknown")
+LOCATION_PROVIDERS["gps"] = "GPS"
+LOCATION_PROVIDERS["network"] = "Wifi Triangulation"

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

@@ -24,6 +24,7 @@ from videogames.howlongtobeat import lookup_game_from_hltb
 from videogames.models import VideoGame
 from videos.models import Video
 from locations.models import GeoLocation, RawGeoLocation
+from vrobbler.apps.locations.constants import LOCATION_PROVIDERS
 
 logger = logging.getLogger(__name__)
 
@@ -273,7 +274,8 @@ def gpslogger_scrobble_location(
     }
 
     scrobble = Scrobble.create_or_update(location, user_id, extra_data)
-    provider = f"gps source - {data_dict.get('prov')}"
+
+    provider = f"data source: {LOCATION_PROVIDERS[data_dict.get('prov')]}"
     if scrobble.notes:
         scrobble.notes = scrobble.notes + f"\n{provider}"
     else: