1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Order cerca by id

This commit is contained in:
Steffo 2019-01-29 13:52:37 +01:00
parent 1c56e9f14b
commit 0a46cbeade

View file

@ -305,7 +305,7 @@ def cmd_cerca(bot: Bot, update: Update):
bot.send_message(update.message.chat.id, s(strings.DIARIO_SEARCH.ERRORS.INVALID_SYNTAX)) bot.send_message(update.message.chat.id, s(strings.DIARIO_SEARCH.ERRORS.INVALID_SYNTAX))
return return
text = text.replace('%', '\\%').replace('_', '\\_') text = text.replace('%', '\\%').replace('_', '\\_')
entries = session.query(db.Diario).filter(db.Diario.text.ilike('%'+text+'%')).all() entries = session.query(db.Diario).filter(db.Diario.text.ilike('%'+text+'%')).order_by(db.Diario.id).all()
msg = f"Risultati della ricerca di {text}:\n" msg = f"Risultati della ricerca di {text}:\n"
for entry in entries[:5]: for entry in entries[:5]:
msg += f'<a href="https://ryg.steffo.eu/diario#entry-{entry.id}">#{entry.id}</a> di {entry.author or "Anonimo"}\n{entry.text}\n\n' msg += f'<a href="https://ryg.steffo.eu/diario#entry-{entry.id}">#{entry.id}</a> di {entry.author or "Anonimo"}\n{entry.text}\n\n'