From 3ccd27de8777d13d824a9a5f2e1d7b329785d501 Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 5 Dec 2019 22:58:06 +0100 Subject: [PATCH] core (memory/sqlite): added `before_uid` filter to retrieve history before a message UID --- sat/bridge/bridge_constructor/bridge_template.ini | 1 + sat/memory/sqlite.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/sat/bridge/bridge_constructor/bridge_template.ini b/sat/bridge/bridge_constructor/bridge_template.ini index 09aa061c..ad221482 100644 --- a/sat/bridge/bridge_constructor/bridge_template.ini +++ b/sat/bridge/bridge_constructor/bridge_template.ini @@ -655,6 +655,7 @@ doc_param_4=filters: patterns to filter the history results, can be: - search: pattern must be in message body or source resource - types: type must be one of those, values are separated by spaces - not_types: type must not be one of those, values are separated by spaces + - before_uid: check only message received before message with given uid doc_param_5=%(doc_profile)s doc_return=Ordered list (by timestamp) of data as in [messageNew] (without final profile) diff --git a/sat/memory/sqlite.py b/sat/memory/sqlite.py index 37d602aa..eb792a1d 100644 --- a/sat/memory/sqlite.py +++ b/sat/memory/sqlite.py @@ -625,6 +625,9 @@ class SqliteStorage(object): if 'timestamp_start' in filters: query_parts.append("AND timestamp>= ?") values.append(float(filters['timestamp_start'])) + if 'before_uid' in filters: + query_parts.append("AND history.rowid<(select rowid from history where uid=?)") + values.append(filters['before_uid']) if 'body' in filters: # TODO: use REGEXP (function to be defined) instead of GLOB: https://www.sqlite.org/lang_expr.html query_parts.append("AND message LIKE ?")