Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions backend/kernelCI_app/views/hardwareSelectorsView.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ def _sanitize_records(self, selectors_raw: list[dict]) -> HardwareSelectorsRespo
}
)

for tree in trees:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: because the difference might be negligible, but with this, we might want to remove the order by on the database query

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ordering in the query is different from what we want (newest-first) and is needed for the DISTINCT ON, we could move all the ordering to the query, but it would increase complexity a little

tree["branches"].sort(
key=lambda branch: (
branch["git_repository_url"],
branch["git_repository_branch"],
)
)
for branch in tree["branches"]:
branch["revisions"].sort(
key=lambda revision: revision["start_time"],
reverse=True,
)

trees.sort(key=lambda tree: tree["tree_name"])

sanitized_trees: list[HardwareSelectorTree] = []
for tree in trees:
branches = [
Expand Down
Loading