Create sync versions of pathway to ingest messages to work around sync-only Django management commands
This commit is contained in:
@@ -280,6 +280,20 @@ class ElasticsearchBackend(StorageBackend):
|
||||
self.log.error(f"Indexing failed: {result}")
|
||||
self.log.debug(f"Indexed {len(matches)} messages in ES")
|
||||
|
||||
def store_matches(self, matches):
|
||||
"""
|
||||
Store a list of matches in Elasticsearch.
|
||||
:param index: The index to store the matches in.
|
||||
:param matches: A list of matches to store.
|
||||
"""
|
||||
if self.client is None:
|
||||
self.initialise()
|
||||
for match in matches:
|
||||
result = self.client.index(index=settings.INDEX_RULE_STORAGE, body=match)
|
||||
if not result["result"] == "created":
|
||||
self.log.error(f"Indexing failed: {result}")
|
||||
self.log.debug(f"Indexed {len(matches)} messages in ES")
|
||||
|
||||
async def schedule_query_results(self, rule_object):
|
||||
"""
|
||||
Helper to run a scheduled query with reduced functionality and async.
|
||||
|
||||
Reference in New Issue
Block a user