Skip to content

Commit

Permalink
Refactor queryPathChanged and queryTraceChanges for improved readabil…
Browse files Browse the repository at this point in the history
…ity and consistency
  • Loading branch information
petya-vasileva committed Jan 26, 2025
1 parent 17fc0d9 commit ca61e8a
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/model/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ def queryPathChanged(dateFrom, dateTo):
data = []

for item in result:
temp = item['_source'].copy()
if 'src_site' in temp.keys() and 'dest_site' in temp.keys():
temp['tag'] = [temp['src_site'], temp['dest_site']]
temp['from'] = temp['from_date']
temp['to'] = temp['to_date']
del temp['from_date']
del temp['to_date']
data.append(temp)
temp = item['_source'].copy()
if 'src_site' in temp.keys() and 'dest_site' in temp.keys():
temp['tag'] = [temp['src_site'], temp['dest_site']]
temp['from'] = temp['from_date']
temp['to'] = temp['to_date']
del temp['from_date']
del temp['to_date']
data.append(temp)

return data

Expand Down Expand Up @@ -469,11 +469,12 @@ def queryTraceChanges(dateFrom, dateTo, asn=None):
data, positions, baseline, altPaths = [],[],[],[]
positions = []
for item in result:
# print(len(data))
item['_source']['src'] = item['_source']['src'].upper()
item['_source']['dest'] = item['_source']['dest'].upper()
item['_source']['src_site'] = item['_source']['src_site'].upper()
item['_source']['dest_site'] = item['_source']['dest_site'].upper()
temp = item['_source']
if 'src_site' in temp.keys() and 'dest_site' in temp.keys():
item['src'] = item['src'].upper()
item['dest'] = item['dest'].upper()
item['src_site'] = item['src_site'].upper()
item['dest_site'] = item['dest_site'].upper()

tempD = {}
for k,v in item['_source'].items():
Expand Down

0 comments on commit ca61e8a

Please sign in to comment.