Skip to content

Commit

Permalink
sort the UUIDs in time order
Browse files Browse the repository at this point in the history
  • Loading branch information
edeutsch committed Oct 21, 2023
1 parent 98a702c commit 0585ddd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions code/ARAX/ResponseCache/recent_uuid_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,29 @@ def get_recent_uuids(self, ars_host='ars.ci.transltr.io', top_n_pks=20):
if container_key not in response_dict:
return( { "status": 404, "title": "Error decoding Response", "detail": f"Cannot decode recent PK list from ARS {ars_host}: cannot find {container_key}", "type": "about:blank" }, 404)

have_timestamps = True
uuid_list = []
for uuid in response_dict[container_key]:
#eprint(f"UUID is {uuid}")
uuid_data = self.get_uuid(ars_host, uuid)
#eprint(json.dumps(uuid_data,indent=2,sort_keys=True))
result = self.summarize_uuid_data(ars_host, uuid_data)
if 'timestamp' not in result:
have_timestamps = False
else:
uuid_list.append( { 'pk': uuid, 'timestamp': result['timestamp'] } )
response['pks'][uuid] = result
response['agents_list'] = result['agents_list']
del(result['agents_list'])
response['pks'][uuid]['ars_host'] = ars_host
#eprint(json.dumps(response,indent=2,sort_keys=True))

if have_timestamps:
uuid_list.sort(key=lambda x: x['timestamp'])
response['sorted_pk_list'] = []
for item in uuid_list:
response['sorted_pk_list'].append(item['pk'])

return response


Expand Down

0 comments on commit 0585ddd

Please sign in to comment.