mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-10-05 17:35:33 -03:00
refactor(update)!: make obtainability a property of updates, not a surface
The owner could not tell from the UI what "Buzz Price Tracking" enabled, what the "Price alert threshold" number meant, or what "Price Alerts" was alerting about. That was not a copy problem: the implementation exposed our mechanism (a page scrape) and our SQL predicates as the user's concepts. Two concrete defects came from the same root: - the alert population included versions the user already owns (neither the event generator nor the query filtered on is_in_library; in the owner's library 28 of 52 gated versions were already downloaded, so most "alerts" were about files already on disk, which cannot become cheaper *for them*); - a threshold-filtered state list lived in a notification surface, so an empty panel had three indistinguishable causes and read as a broken feature. The information model is now the version plus ownership: cost is shown only where a decision exists. Owned -> nothing. Not owned and free -> nothing. Not owned and gated -> the price when it is known, `Paid` without a number when it is not, and early access keeps its countdown because "free on <date>" decides between waiting and paying. The numeric threshold has no place in that model: every decision is categorical (wait / pay / skip), so the setting, the comparison and the whole alert-state machine are gone. - both alert-state columns are removed from the schema rather than left dead; a database created by an unreleased build has them dropped on open (native ALTER TABLE ... DROP COLUMN, guarded), which is a no-op for everyone else - gate events are emitted only for versions the user does not have, and the price-drop event goes with the threshold it belonged to - both alert endpoints, PriceAlertsHandler and the service-registry adapter field it needed are removed: events already reach the UI through the refresh response - the bell tab, panel, CSS, both entry points, the unread watermark and their locales are removed; the setting keeps only the enable flag and the refresh interval and is framed as plumbing - "Price unavailable" is replaced by `Paid`: the gate is certain from the public API, only the number is best-effort, and that is our plumbing, not the user's problem Verified against a copy of the owner's real database: 52 gated versions -> 28 owned (now silent) + 24 the feature is actually about; the drop migration ran and both removed endpoints 404.
This commit is contained in:
@@ -326,39 +326,6 @@ async def test_refresh_model_updates_filters_records_without_updates():
|
||||
assert call["target_model_ids"] is None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_price_alerts_returns_flagged_versions():
|
||||
"""The price alert list is a GET (companion-extension friendly) and reports
|
||||
the threshold it was computed with."""
|
||||
|
||||
class AlertsService:
|
||||
def __init__(self):
|
||||
self.calls = []
|
||||
|
||||
async def get_price_alerts(self, model_type, limit=200):
|
||||
self.calls.append((model_type, limit))
|
||||
return [{"modelId": 1, "versionId": 12, "priceBuzz": 250}]
|
||||
|
||||
update_service = AlertsService()
|
||||
settings = {"price_tracking_enabled": True, "price_alert_threshold_buzz": 300}
|
||||
handler = ModelUpdateHandler(
|
||||
service=DummyService(SimpleNamespace(version_index={})),
|
||||
update_service=update_service,
|
||||
metadata_provider_selector=lambda *_: None,
|
||||
settings_service=SimpleNamespace(get=lambda key, default=None: settings.get(key, default)),
|
||||
logger=logging.getLogger(__name__),
|
||||
)
|
||||
request = SimpleNamespace(query={"limit": "50"})
|
||||
|
||||
response = await handler.get_price_alerts(request) # pyright: ignore[reportArgumentType]
|
||||
|
||||
assert response.status == 200
|
||||
payload = json.loads(response.text)
|
||||
assert payload["success"] is True
|
||||
assert payload["enabled"] is True
|
||||
assert payload["thresholdBuzz"] == 300
|
||||
assert payload["alerts"] == [{"modelId": 1, "versionId": 12, "priceBuzz": 250}]
|
||||
assert update_service.calls == [("lora", 50)]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -1216,13 +1183,12 @@ def test_every_common_route_definition_resolves_to_a_handler():
|
||||
assert missing == []
|
||||
|
||||
|
||||
def test_get_price_alerts_is_registered_as_a_route():
|
||||
"""The alerts endpoint must be declared and reachable via GET."""
|
||||
def test_price_alert_endpoints_are_not_registered():
|
||||
"""The redesign dropped the standalone alerts surface: obtainability rides on
|
||||
the update surfaces, so no per-type alert route may remain."""
|
||||
|
||||
definition = next(
|
||||
d
|
||||
for d in COMMON_ROUTE_DEFINITIONS
|
||||
if d.handler_name == "get_price_alerts"
|
||||
)
|
||||
assert definition.method == "GET"
|
||||
assert definition.build_path("loras") == "/api/lm/loras/updates/price-alerts"
|
||||
assert [
|
||||
definition.path_template
|
||||
for definition in COMMON_ROUTE_DEFINITIONS
|
||||
if "price-alert" in definition.path_template
|
||||
] == []
|
||||
|
||||
Reference in New Issue
Block a user