fix: sorting by distance

main
Khiem Ton 2 years ago
parent 76fbf9b46d
commit 97a0c667e7
Signed by: th4tkh13m
GPG Key ID: 4D9CF147DCADD05D

@ -50,7 +50,10 @@ class PokemonList:
with Session(self.engine) as session:
result = session.query(Pokemon).where(Pokemon.end_time > datetime.now() + self.timedelta)
session.commit()
return result.all().sort(key=lambda pokemon: location.distance(pokemon.location), reverse=reverse)
print(len(result.all()))
print(type(result.all()))
print(result.all().sort(key=lambda pokemon: location.distance(pokemon.location), reverse=reverse))
return sorted(result.all(), key=lambda pokemon: location.distance(pokemon.location), reverse=reverse)
def search_by_name(self, query: str):
with Session(self.engine) as session:

Loading…
Cancel
Save