Skip to content

Commit

Permalink
moved destination check behind cache as mentioned in #492
Browse files Browse the repository at this point in the history
  • Loading branch information
Der-Henning committed May 1, 2024
1 parent e302b47 commit 78c4c82
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tgtg_scanner/models/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ def calculate_distance_time(self, destination: str, travel_mode: str) -> Union[D
log.debug("Location service disabled")
return None

if not self._is_address_valid(destination):
return None

key = f"{destination}_{travel_mode}"

# use cached value if available
if key in self.distancetime_dict:
return self.distancetime_dict[key]

if not self._is_address_valid(destination):
return None

log.debug(f"Sending Google Maps API request: {destination} using {travel_mode} mode")

# calculate distance and time
Expand Down

0 comments on commit 78c4c82

Please sign in to comment.