Skip to content

Commit 9ac1dc6

Browse files
authored
fix: Use same sort keys for listings of trees on HardwareDetails page. (#1908)
There were instances of sorting the lists of trees in the hardware page using a different set of keys (due to mistake on the performance improvements of #1832). This case might have not triggered, because the sorting provided by the first 2 keys tree_name/branch, might suffice for basically most of the comparisons. * All of them are now using the keys (in order of importance): 1. tree_name 2. branch, 3. git_repository_url 4. git_commit_hash Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
1 parent b57ace3 commit 9ac1dc6

1 file changed

Lines changed: 25 additions & 23 deletions

File tree

backend/kernelCI_app/views/hardwareDetailsSummaryView.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -330,40 +330,42 @@ def aggregate_common(
330330
status_count = StatusCount()
331331
status_count.increment(status, count)
332332

333-
if (tree_name, git_repository_url, git_repository_branch) not in all_trees:
334-
all_trees[(tree_name, git_repository_url, git_repository_branch)] = (
335-
Tree(
336-
index="", # if we dont mind to sort, we can just use len(all_trees)
337-
tree_name=tree_name,
338-
git_repository_branch=git_repository_branch,
339-
git_repository_url=git_repository_url,
340-
head_git_commit_hash=git_commit_hash,
341-
head_git_commit_name=git_commit_name,
342-
head_git_commit_tag=git_commit_tags,
343-
origin=origin,
344-
selected_commit_status={
345-
"builds": StatusCount(),
346-
"boots": StatusCount(),
347-
"tests": StatusCount(),
348-
},
349-
is_selected=None,
350-
)
333+
tree_key = (
334+
tree_name,
335+
git_repository_url,
336+
git_repository_branch,
337+
git_commit_hash,
338+
)
339+
if tree_key not in all_trees:
340+
all_trees[tree_key] = Tree(
341+
index="",
342+
tree_name=tree_name,
343+
git_repository_branch=git_repository_branch,
344+
git_repository_url=git_repository_url,
345+
head_git_commit_hash=git_commit_hash,
346+
head_git_commit_name=git_commit_name,
347+
head_git_commit_tag=git_commit_tags,
348+
origin=origin,
349+
selected_commit_status={
350+
"builds": StatusCount(),
351+
"boots": StatusCount(),
352+
"tests": StatusCount(),
353+
},
354+
is_selected=None,
351355
)
352356
row_type = self.get_summary_type(**instance)
353-
all_trees[
354-
(tree_name, git_repository_url, git_repository_branch)
355-
].selected_commit_status[row_type] += status_count
357+
all_trees[tree_key].selected_commit_status[row_type] += status_count
356358
all_compatibles.update(compatibles or [])
357359

358360
all_compatibles.discard(hardware_id)
359361

360-
# not sure if it is worth sorting for index (but is also not slowing us down)
361362
sorted_trees = sorted(
362363
all_trees.values(),
363364
key=lambda t: (
364365
t.tree_name or "",
365366
t.git_repository_branch or "",
366-
t.head_git_commit_name or "",
367+
t.git_repository_url or "",
368+
t.head_git_commit_hash or "",
367369
),
368370
)
369371
for i, tree in enumerate(sorted_trees):

0 commit comments

Comments
 (0)