From 0a46cbeade5587e973153f5a768cfd7b117640e8 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 29 Jan 2019 13:52:37 +0100 Subject: [PATCH] Order cerca by id --- telegrambot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telegrambot.py b/telegrambot.py index 1921433a..d6389858 100644 --- a/telegrambot.py +++ b/telegrambot.py @@ -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)) return 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" for entry in entries[:5]: msg += f'#{entry.id} di {entry.author or "Anonimo"}\n{entry.text}\n\n'