Skip to content

Commit 296942f

Browse files
author
Caspar van Leeuwen
committed
Fix some bugs. Also, make sure to actually use the sorted table when composing the table with only the last builds. Finally, add resorting for an output that is sorted alphabetically by 'for' architecture
1 parent 25dd76d commit 296942f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

eessi_bot_event_handler.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ def handle_bot_command_status(self, event_info, bot_command):
599599
dates = status_table['date']
600600
timestamps = []
601601
for date in dates:
602-
date_object = datetime.datetime.strptime(date, "%b %d %X %Z %Y")
602+
date_object = datetime.strptime(date, "%b %d %X %Z %Y")
603603
timestamps.append(int(date_object.timestamp()))
604604
status_table['timestamp'] = timestamps
605605

@@ -609,16 +609,23 @@ def handle_bot_command_status(self, event_info, bot_command):
609609
sorted_indices.reverse()
610610
# Apply the sorted indices to get a sorted table
611611
sorted_table = {key: [status_table[key][i] for i in sorted_indices] for key in status_table}
612+
self.log(f"Sorted status table: {sorted_table}")
612613

613614
# Keep only the first entry for each 'for arch', as that is now the newest
614615
status_table_last = {'on arch': [], 'for arch': [], 'for repo': [], 'date': [], 'status': [], 'url': [], 'result': []}
615-
for x in range(0, len(status_table['date'])):
616-
if status_table['for arch'][x] not in status_table_last['for arch']:
616+
for x in range(0, len(sorted_table['date'])):
617+
if sorted_table['for arch'][x] not in status_table_last['for arch']:
618+
self.log(f"arch: {sorted_table['for arch'][x]} not yet in status_table_last")
617619
for key in status_table_last:
618-
status_table_last[key].append(status_table[key][x])
620+
self.log(f"Adding to '{key}' and the value {sorted_table[key][x]}")
621+
status_table_last[key].append(sorted_table[key][x])
622+
623+
# Re-sort, now only on 'for arch', for nicer viewing
624+
sorted_indices = sorted(range(len(status_table_last['for arch'])), key=lambda x: status_table_last['for arch'][x])
625+
sorted_table_last = {key: [status_table_last[key][i] for i in sorted_indices] for key in status_table_last}
619626

620627
# overwrite the original status_table
621-
status_table = status_table_last
628+
status_table = sorted_table_last
622629

623630
comment_status = ''
624631
comment_status += "\nThis is the status of all the `bot: build` commands:"

0 commit comments

Comments
 (0)