Fix stove material matching for site bill
This commit is contained in:
+10
-2
@@ -68,6 +68,10 @@ def _reserve(key_id: int, budget: float, profile) -> int:
|
||||
|
||||
def _candidates(name: str, unit: str, region: str, zone: str | None) -> list[dict]:
|
||||
found = fgis_ref.find_resource_price(query=name, region=region, zone=zone, limit=12)
|
||||
return _candidate_rows(found, unit)
|
||||
|
||||
|
||||
def _candidate_rows(found: dict, unit: str) -> list[dict]:
|
||||
if found.get("status") == "db_unavailable":
|
||||
raise MatchingUnavailable(30)
|
||||
if found.get("status") != "ok" or found.get("multiple_zones"):
|
||||
@@ -184,8 +188,12 @@ async def fill(prices: dict, *, key_id: int, budget: float, deadline: float, req
|
||||
await asyncio.to_thread(stove_cache.match_delete, ck)
|
||||
else:
|
||||
continue
|
||||
candidates = await asyncio.to_thread(_candidates, line["name"], line["unit"],
|
||||
prices["region"], prices.get("zone"))
|
||||
found = prices.get("search_results", {}).get(index)
|
||||
if found is not None:
|
||||
candidates = _candidate_rows(found, line["unit"])
|
||||
else:
|
||||
candidates = await asyncio.to_thread(_candidates, line["name"], line["unit"],
|
||||
prices["region"], prices.get("zone"))
|
||||
if candidates:
|
||||
todo.append({"index": index, "line": line, "candidates": candidates, "cache_key": ck})
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user