T53161 all py.test things PASSES
This commit is contained in:
parent
fccd3e306e
commit
3bdd5197f5
@ -101,7 +101,16 @@ class Node(es.DocType):
|
||||
|
||||
|
||||
def create_doc_from_user_data(user_to_index):
|
||||
doc_id = str(user_to_index['objectID'])
|
||||
|
||||
if not user_to_index:
|
||||
return
|
||||
|
||||
doc_id = str(user_to_index.get('objectID', ''))
|
||||
|
||||
if not doc_id:
|
||||
log.error('ID missing %s', user_to_index)
|
||||
return
|
||||
|
||||
doc = User(_id=doc_id)
|
||||
doc.objectID = str(user_to_index['objectID'])
|
||||
doc.username = user_to_index['username']
|
||||
@ -114,6 +123,9 @@ def create_doc_from_user_data(user_to_index):
|
||||
|
||||
def create_doc_from_node_data(node_to_index):
|
||||
|
||||
if not node_to_index:
|
||||
return
|
||||
|
||||
# node stuff
|
||||
doc_id = str(node_to_index.get('objectID', ''))
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
import logging
|
||||
|
||||
from elasticsearch_dsl.connections import connections
|
||||
from elasticsearch.exceptions import NotFoundError
|
||||
|
||||
from pillar import current_app
|
||||
from . import documents
|
||||
@ -21,7 +22,14 @@ def push_updated_user(user_to_index: dict):
|
||||
Push an update to the Elastic index when
|
||||
a user item is updated.
|
||||
"""
|
||||
if not user_to_index:
|
||||
return
|
||||
|
||||
doc = documents.create_doc_from_user_data(user_to_index)
|
||||
|
||||
if not doc:
|
||||
return
|
||||
|
||||
log.debug('UPDATE USER %s', doc._id)
|
||||
doc.save()
|
||||
|
||||
@ -33,6 +41,9 @@ def index_node_save(node_to_index: dict):
|
||||
|
||||
doc = documents.create_doc_from_node_data(node_to_index)
|
||||
|
||||
if not doc:
|
||||
return
|
||||
|
||||
log.debug('CREATED ELK NODE DOC %s', doc._id)
|
||||
doc.save()
|
||||
|
||||
@ -40,4 +51,9 @@ def index_node_save(node_to_index: dict):
|
||||
def index_node_delete(delete_id: str):
|
||||
|
||||
log.debug('NODE DELETE INDEXING %s', delete_id)
|
||||
documents.Node(id=delete_id).delete()
|
||||
|
||||
try:
|
||||
doc = documents.Node.get(id=delete_id)
|
||||
doc.delete()
|
||||
except NotFoundError:
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user