Skip to content

Commit 55c6fde

Browse files
author
Ruinong Tian
committed
fix staleness report download count column sort logic
1 parent ec5c2bb commit 55c6fde

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/package_report.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,23 @@ def _generate_staleness_report_per_image(
106106
}
107107
)
108108

109-
staleness_report_rows.sort(
110-
key=lambda x: (
111-
not x["package"].startswith("${\\color"), # Stale packages at top of list
112-
-x["downloads"], # Sorted by downloads
113-
)
114-
)
109+
def sort_key(x):
110+
# First key: False for stale packages (they start with "${\\color")
111+
is_current = not x["package"].startswith("${\\color")
112+
113+
# Second key: downloads count, with "N/A" treated as lowest priority
114+
downloads = x["downloads"]
115+
if downloads == "N/A":
116+
download_value = float('-inf') # Put N/A at the bottom
117+
else:
118+
try:
119+
download_value = float(downloads)
120+
except (ValueError, TypeError):
121+
download_value = float('-inf') # Handle any other non-numeric values
122+
123+
return (is_current, download_value)
124+
125+
staleness_report_rows.sort(key=sort_key, reverse=True)
115126
print(
116127
create_markdown_table(
117128
[

0 commit comments

Comments
 (0)