fix(ui): explain a 0 Buzz threshold in the price alerts panel

The default threshold is 0 ("only tell me when a version becomes free") and the
settings copy says so, but the panel did not: a real instance with 52 priced paid
versions and an untouched threshold showed "Nothing is under your price threshold
right now" with only a small "Alert threshold: 0 Buzz" in the corner, which reads
as a broken feature.

- the payload now carries pricedCount, so the empty state can say how many paid
  versions already have a known price
- when the threshold is 0 and prices are known, the empty state says so and
  points at Settings - Library instead of implying there is nothing to show
- the read-time threshold comparison means setting one takes effect immediately;
  measured on a copy of that instance: 0 Buzz -> 0 alerts, 100 -> 44,
  500 -> 48, 5000 -> 51
This commit is contained in:
Will Miao
2026-10-04 20:28:57 +08:00
parent 425d90a912
commit 156d2e5eb9
17 changed files with 148 additions and 23 deletions
+30
View File
@@ -1362,6 +1362,36 @@ class ModelUpdateService:
return None
return float(row["newest"])
def count_priced_versions(self, model_type: Optional[str] = None) -> int:
"""Versions with a known price, for the panel's empty state.
Without it, a user whose threshold is 0 sees "nothing is under your price
threshold" while dozens of paid versions already have a price.
"""
params: List[Any] = []
type_filter = ""
if model_type:
type_filter = "AND s.model_type = ?"
params.append(model_type)
with self._connect() as conn:
row = conn.execute(
f"""
SELECT COUNT(*) AS priced
FROM model_update_versions v
JOIN model_update_status s ON s.model_id = v.model_id
WHERE v.should_ignore = 0
AND s.should_ignore_model = 0
{type_filter}
AND v.price_buzz IS NOT NULL
""",
tuple(params),
).fetchone()
if row is None:
return 0
return int(row["priced"])
def count_unavailable_prices(self, model_type: Optional[str] = None) -> int:
"""Gated versions whose price we tried to read and could not.