[scrobbling] Fix scrobble overwriting bug and refactor location scrobbling

This commit is contained in:
2024-02-12 11:34:06 -05:00
parent 36bc1c2e95
commit 2c26cc01ba
2 changed files with 50 additions and 43 deletions

View File

@ -91,20 +91,19 @@ class GeoLocation(ScrobblableMixin):
abs(Decimal(old_lat_lon[1]) - Decimal(self.lon)),
)
def has_moved(self, past_points) -> bool:
def has_moved(self, past_points: list["GeoLocation"]) -> bool:
has_moved = False
all_moves = []
for point in past_points:
loc_diff = self.loc_diff((point.lat, point.lon))
logger.info(f"[locations] {self} is {loc_diff} from {point}")
if (
loc_diff[0] > GEOLOC_PROXIMITY
or loc_diff[1] > GEOLOC_PROXIMITY
):
all_moves.append(True)
if True in all_moves:
has_moved = True
logger.info(
f"[locations] {loc_diff} is greater than proximity setting {GEOLOC_PROXIMITY}, moving"
)
has_moved = True
return has_moved