Open abompard opened 2 months ago
Now that there is a JSONB index on the headers column, we could add a grep argument that would make use of it. It could look something like:
headers
--- a/datanommer.models/datanommer/models/__init__.py +++ b/datanommer.models/datanommer/models/__init__.py @@ -395,6 +395,8 @@ class Message(DeclarativeBase): not_topics=None, agents=None, not_agents=None, + headers_jsons=None, + headers_jsons_and=None, contains=None, ): """Flexible query interface for messages. @@ -436,6 +438,8 @@ class Message(DeclarativeBase): not_topics = not_topics or [] agents = agents or [] not_agents = not_agents or [] + headers_jsons = headers_jsons or [] + headers_jsons_and = headers_jsons_and or [] contains = contains or [] Message = cls @@ -470,6 +474,11 @@ class Message(DeclarativeBase): if agents: query = query.where(or_(*(Message.agent_name == agent for agent in agents))) + if headers_jsons: + query = query.where(or_(*(Message.headers.path_match(path) for path in headers_jsons))) + if headers_jsons_and: + query = query.where(and_(*(Message.headers.path_match(path) for path in headers_jsons_and))) + if contains: query = query.where(or_(*(Message.msg.like(f"%{contain}%") for contain in contains)))
Now that there is a JSONB index on the
headers
column, we could add a grep argument that would make use of it. It could look something like: