mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
feat(usage_count): sorting by usage_count + usage_count on ModelCard
This commit is contained in:
@@ -13,7 +13,10 @@ SUPPORTED_SORT_MODES = [
|
||||
('date', 'desc'),
|
||||
('size', 'asc'),
|
||||
('size', 'desc'),
|
||||
('usage', 'asc'),
|
||||
('usage', 'desc'),
|
||||
]
|
||||
# Is this in use?
|
||||
|
||||
DISPLAY_NAME_MODES = {"model_name", "file_name"}
|
||||
|
||||
@@ -234,6 +237,16 @@ class ModelCache:
|
||||
key=itemgetter('size'),
|
||||
reverse=reverse
|
||||
)
|
||||
elif sort_key == 'usage':
|
||||
# Sort by usage count, fallback to 0, then name for stability
|
||||
return sorted(
|
||||
data,
|
||||
key=lambda x: (
|
||||
x.get('usage_count', 0),
|
||||
self._get_display_name(x).lower()
|
||||
),
|
||||
reverse=reverse
|
||||
)
|
||||
else:
|
||||
# Fallback: no sort
|
||||
return list(data)
|
||||
|
||||
Reference in New Issue
Block a user