Update accuracy of geolocations
This commit is contained in:
@ -13,6 +13,7 @@ logger = logging.getLogger(__name__)
|
||||
BNULL = {"blank": True, "null": True}
|
||||
User = get_user_model()
|
||||
|
||||
ACCURACY = getattr(settings, "GEOLOC_ACCURACY", 3)
|
||||
|
||||
class GeoLocation(ScrobblableMixin):
|
||||
COMPLETION_PERCENT = getattr(settings, "LOCATION_COMPLETION_PERCENT", 100)
|
||||
@ -53,11 +54,11 @@ class GeoLocation(ScrobblableMixin):
|
||||
int_lon, r_lon = str(data_dict.get("lon", "")).split(".")
|
||||
|
||||
try:
|
||||
trunc_lat = r_lat[0:4]
|
||||
trunc_lat = r_lat[0:GEOLOC_ACCURACY]
|
||||
except IndexError:
|
||||
trunc_lat = r_lat
|
||||
try:
|
||||
trunc_lon = r_lon[0:4]
|
||||
trunc_lon = r_lon[0:GEOLOC_ACCURACY]
|
||||
except IndexError:
|
||||
trunc_lon = r_lon
|
||||
|
||||
@ -65,12 +66,8 @@ class GeoLocation(ScrobblableMixin):
|
||||
data_dict["lon"] = float(f"{int_lon}.{trunc_lon}")
|
||||
|
||||
int_alt, r_alt = str(data_dict.get("alt", "")).split(".")
|
||||
try:
|
||||
trunc_alt = r_lon[0:4]
|
||||
except IndexError:
|
||||
trunc_alt = r_alt
|
||||
|
||||
data_dict["altitude"] = float(f"{int_alt}.{trunc_alt}")
|
||||
data_dict["altitude"] = float(int_alt)
|
||||
|
||||
location = cls.objects.filter(
|
||||
lat=data_dict.get("lat"),
|
||||
|
||||
@ -65,6 +65,7 @@ LASTFM_API_KEY = os.getenv("VROBBLER_LASTFM_API_KEY")
|
||||
LASTFM_SECRET_KEY = os.getenv("VROBBLER_LASTFM_SECRET_KEY")
|
||||
IGDB_CLIENT_ID = os.getenv("VROBBLER_IGDB_CLIENT_ID")
|
||||
IGDB_CLIENT_SECRET = os.getenv("VROBBLER_IGDB_CLIENT_SECRET")
|
||||
GEOLOC_ACCURACY = os.getenv("VROBBLER_GEOLOC_ACCURACY", 3)
|
||||
|
||||
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user