core (memory/sqlite): added before_uid filter to retrieve history before a message UID

This commit is contained in:
Goffi 2019-12-05 22:58:06 +01:00
commit 3ccd27de87
2 changed files with 4 additions and 0 deletions

View file

@ -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)

View file

@ -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 ?")