diff --git a/tr_sys/tr_ars/api.py b/tr_sys/tr_ars/api.py index 3613cd83..303c8ac1 100644 --- a/tr_sys/tr_ars/api.py +++ b/tr_sys/tr_ars/api.py @@ -447,7 +447,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) @@ -456,6 +455,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) diff --git a/tr_sys/tr_ars/utils.py b/tr_sys/tr_ars/utils.py index 19a71672..8da99c0c 100644 --- a/tr_sys/tr_ars/utils.py +++ b/tr_sys/tr_ars/utils.py @@ -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, data, blocklist=None): if blocklist is None: @@ -751,17 +751,19 @@ 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)) if edgeId not in sources_to_remove.keys(): sources_to_remove[edgeId]=[edge_source] else: sources_to_remove[edgeId].append(edge_source) - if 'upstream_resource_ids' not in edge_source.keys() or ('upstream_resource_ids' in edge_source.keys() and edge_source["upstream_resource_ids"] is None): - logging.info('found Null in upstream_resource_ids : %s' % (edge_source)) - edge_source["upstream_resource_ids"]=[] - if 'upstream_resource_ids' in edge_source.keys() and isinstance(edge_source['upstream_resource_ids'], list): - while None in edge_source["upstream_resource_ids"]: - edge_source["upstream_resource_ids"].remove(None) if len(sources_to_remove)>0: bad_sources.append(sources_to_remove)