1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

search order is now descending

This commit is contained in:
Fabio De Simone 2019-01-29 15:07:36 +01:00
parent bd672f9330
commit 6ffd255407

View file

@ -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)) bot.send_message(update.message.chat.id, s(strings.DIARIO_SEARCH.ERRORS.INVALID_SYNTAX))
return return
queryText = queryText.replace('%', '\\%').replace('_', '\\_') 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) cerca_message(bot, update, queryText, entries)
finally: finally:
session.close() 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)) bot.send_message(update.message.chat.id, s(strings.DIARIO_SEARCH.ERRORS.INVALID_SYNTAX))
return return
queryText = queryText.replace('%', '\\%').replace('_', '\\_') 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) cerca_message(bot, update, queryText, entries)
finally: finally:
session.close() session.close()