Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mesg save for 0 results return to ARS #543

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tr_sys/tr_ars/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ def message(req, key):
utils.merge_and_post_process.apply_async((parent_pk,message_to_merge['message'],agent_name))
logger.info("post async call for agent %s" % agent_name)


# create child message if this one already has results
if mesg.data and 'results' in mesg.data and mesg.data['results'] != None and len(mesg.data['results']) > 0:
mesg = Message.create(name=mesg.name, status=status, actor=mesg.actor, ref=mesg)
Expand All @@ -455,6 +454,11 @@ def message(req, key):
mesg.data = data
mesg.save()

if len(res) == 0:
mesg.result_count = 0
mesg.code = code
mesg.status = status
mesg.save()

return HttpResponse(json.dumps(mesg.to_dict(), indent=2),
status=201)
Expand Down
10 changes: 5 additions & 5 deletions tr_sys/tr_ars/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,9 @@ def merge_and_post_process(parent_pk,message_to_merge, agent_name):
logging.info('merged data for agent %s with pk %s is returned & ready to be preprocessed' % (agent_name, str(merged.id)))
post_process(merged.data,merged.id, agent_name)

parent.code = 200
parent.status = 'D'
parent.save()
# parent.code = 200
# parent.status = 'D'
# parent.save()

def remove_blocked(mesg, blocklist=None):
if blocklist is None:
Expand Down Expand Up @@ -745,14 +745,14 @@ def scrub_null_attributes(data):
sources_to_remove = {}
for edge_source in edgeSources:
if 'resource_id' not in edge_source.keys() or edge_source["resource_id"] is None:
logging.info('found Null in resource_id : %s' % (edge_source))
#logging.info('found Null in resource_id : %s' % (edge_source))
if edgeId not in sources_to_remove.keys():
sources_to_remove[edgeId]=[edge_source]
else:
sources_to_remove[edgeId].append(edge_source)
elif 'upstream_resource_id' not in edge_source.keys() or ('upstream_resource_ids' in edge_source.keys() and edge_source["upstream_resource_ids"] is None)\
or edge_source["upstream_resource_ids"] is [None]:
logging.info('found Null in upstream_resource_ids : %s' % (edge_source))
#logging.info('found Null in upstream_resource_ids : %s' % (edge_source))
if edgeId not in sources_to_remove.keys():
sources_to_remove[edgeId]=[edge_source]
else:
Expand Down