Fixed stupid mistake of using an empty list

This commit is contained in:
Profitroll 2023-08-30 14:03:08 +02:00
parent 1248efd20f
commit 0006703daf
Signed by: profitroll
GPG Key ID: FA35CAB49DACD3B2
2 changed files with 6 additions and 2 deletions

View File

@ -46,7 +46,7 @@ async def search_name(app: PyroClient, message: Message) -> Union[Location, None
query = {"$text": {"$search": answer.text}} query = {"$text": {"$search": answer.text}}
locations = (await col_locations.find(query).limit(6).to_list()).reverse() locations = await col_locations.find(query).limit(6).to_list()
if len(locations) == 0: if len(locations) == 0:
await message.reply_text( await message.reply_text(
@ -61,6 +61,8 @@ async def search_name(app: PyroClient, message: Message) -> Union[Location, None
) )
continue continue
locations = locations.reverse()
keyboard = ReplyKeyboard(resize_keyboard=True, row_width=2) keyboard = ReplyKeyboard(resize_keyboard=True, row_width=2)
keyboard.add(*[ReplyButton(db_record["name"]) for db_record in locations]) keyboard.add(*[ReplyButton(db_record["name"]) for db_record in locations])

View File

@ -24,7 +24,7 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No
} }
} }
locations = (await col_locations.find(query).limit(6).to_list()).reverse() locations = await col_locations.find(query).limit(6).to_list()
if len(locations) == 0: if len(locations) == 0:
await message.reply_text( await message.reply_text(
@ -32,6 +32,8 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No
) )
return await search_name(app, message) return await search_name(app, message)
locations = locations.reverse()
keyboard = ReplyKeyboard(resize_keyboard=True, row_width=2) keyboard = ReplyKeyboard(resize_keyboard=True, row_width=2)
keyboard.add(*[ReplyButton(db_record["name"]) for db_record in locations]) keyboard.add(*[ReplyButton(db_record["name"]) for db_record in locations])