From 6ffd255407f0987a175aea62dfd920d57eeedb37 Mon Sep 17 00:00:00 2001 From: Fabio De Simone Date: Tue, 29 Jan 2019 15:07:36 +0100 Subject: [PATCH] search order is now descending --- telegrambot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/telegrambot.py b/telegrambot.py index 351a996c..74e84044 100644 --- a/telegrambot.py +++ b/telegrambot.py @@ -306,7 +306,7 @@ def cmd_cerca(bot: Bot, update: Update): bot.send_message(update.message.chat.id, s(strings.DIARIO_SEARCH.ERRORS.INVALID_SYNTAX)) return queryText = queryText.replace('%', '\\%').replace('_', '\\_') - entries = session.query(db.Diario).filter(text(f"text ~* '(?:[^\w\d]+{queryText}[^\w\d]+|^{queryText}[^\w\d]+|^{queryText}$|[^\w\d]+{queryText}$)'")).order_by(db.Diario.id).all() + entries = session.query(db.Diario).filter(text(f"text ~* '(?:[^\w\d]+{queryText}[^\w\d]+|^{queryText}[^\w\d]+|^{queryText}$|[^\w\d]+{queryText}$)'")).order_by(db.Diario.id.desc()).all() cerca_message(bot, update, queryText, entries) finally: session.close() @@ -321,7 +321,7 @@ def cmd_regex_diario(bot: Bot, update: Update): bot.send_message(update.message.chat.id, s(strings.DIARIO_SEARCH.ERRORS.INVALID_SYNTAX)) return queryText = queryText.replace('%', '\\%').replace('_', '\\_') - entries = session.query(db.Diario).filter(text(f"text ~* '{queryText}'")).order_by(db.Diario.id).all() + entries = session.query(db.Diario).filter(text(f"text ~* '{queryText}'")).order_by(db.Diario.id.desc()).all() cerca_message(bot, update, queryText, entries) finally: session.close()