Skip to content

Commit

Permalink
review: small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cdelabre committed Oct 16, 2024
1 parent 3b43983 commit b11267f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions apps/recommendation/api/src/huggy/core/scorer/offer.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,16 @@ async def get_distance(
async def get_mean_offer_coordinates(
self, input_offers: t.Optional[list[o.Offer]] = None
) -> tuple[t.Optional[float], t.Optional[float]]:
geolocated_offers = [offer for offer in input_offers if offer.is_geolocated]
if len(geolocated_offers) > 0:
longitude = sum([offer.longitude for offer in geolocated_offers]) / len(
geolocated_offers
)
latitude = sum([offer.latitude for offer in geolocated_offers]) / len(
geolocated_offers
)
return latitude, longitude
if input_offers:
geolocated_offers = [offer for offer in input_offers if offer.is_geolocated]
if len(geolocated_offers) > 0:
longitude = sum([offer.longitude for offer in geolocated_offers]) / len(
geolocated_offers
)
latitude = sum([offer.latitude for offer in geolocated_offers]) / len(
geolocated_offers
)
return latitude, longitude
return None, None

async def get_nearest_offers(
Expand Down

0 comments on commit b11267f

Please sign in to comment.