Fix scrobbling of locations
This commit is contained in:
@ -55,17 +55,9 @@ class GeoLocation(ScrobblableMixin):
|
|||||||
logger.error("No lat or lon keys in data dict")
|
logger.error("No lat or lon keys in data dict")
|
||||||
return
|
return
|
||||||
|
|
||||||
lat_int, lat_places = data_dict.get("lat", "").split(".")
|
data_dict["lat"] = float(data_dict.get("lat", ""))
|
||||||
lon_int, lon_places = data_dict.get("lon", "").split(".")
|
data_dict["lon"] = float(data_dict.get("lon", ""))
|
||||||
alt_int, alt_places = data_dict.get("alt", "").split(".")
|
data_dict["altitude"] = float(data_dict.get("alt", ""))
|
||||||
|
|
||||||
truncated_lat = lat_places[0:5]
|
|
||||||
truncated_lon = lon_places[0:5]
|
|
||||||
truncated_alt = alt_places[0:3]
|
|
||||||
|
|
||||||
data_dict["lat"] = float(".".join([lat_int, truncated_lat]))
|
|
||||||
data_dict["lon"] = float(".".join([lon_int, truncated_lon]))
|
|
||||||
data_dict["altitude"] = float(".".join([alt_int, truncated_alt]))
|
|
||||||
|
|
||||||
location = cls.objects.filter(
|
location = cls.objects.filter(
|
||||||
lat=data_dict.get("lat"),
|
lat=data_dict.get("lat"),
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from scrobbles.stats import get_scrobble_count_qs
|
|||||||
|
|
||||||
class GeoLocationListView(generic.ListView):
|
class GeoLocationListView(generic.ListView):
|
||||||
model = GeoLocation
|
model = GeoLocation
|
||||||
paginate_by = 200
|
paginate_by = 75
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return super().get_queryset().order_by("-created")
|
return super().get_queryset().order_by("-created")
|
||||||
|
|||||||
@ -630,8 +630,14 @@ class Scrobble(TimeStampedModel):
|
|||||||
if self.media_obj.__class__.__name__ in ["GeoLocation"]:
|
if self.media_obj.__class__.__name__ in ["GeoLocation"]:
|
||||||
logger.info(f"Calculate proximity to last scrobble")
|
logger.info(f"Calculate proximity to last scrobble")
|
||||||
if self.previous:
|
if self.previous:
|
||||||
same_lat = self.previous.media_obj.lat == self.media_obj.lat
|
same_lat = (
|
||||||
same_lon = self.previous.media_obj.lon == self.media_obj.lon
|
self.previous.media_obj.truncated_lat
|
||||||
|
== self.media_obj.truncated_lat
|
||||||
|
)
|
||||||
|
same_lon = (
|
||||||
|
self.previous.media_obj.truncated_lon
|
||||||
|
== self.media_obj.truncated_lon
|
||||||
|
)
|
||||||
if same_lat and same_lon: # We have moved
|
if same_lat and same_lon: # We have moved
|
||||||
logger.info("Yes - We're in the same place!")
|
logger.info("Yes - We're in the same place!")
|
||||||
updatable = True
|
updatable = True
|
||||||
|
|||||||
Reference in New Issue
Block a user