优化:未分类连续维护与柏拉图预汇总,同步已发布修复
This commit is contained in:
@@ -203,11 +203,12 @@ def normalize_query_plan(value, *, root_task, root_value=None, context=None):
|
||||
if (source is None or source["purpose"] != "ranking" or source["dimension"] != "product"
|
||||
or source["selector"].get("kind") != "base"):
|
||||
raise ValueError(f"queryPlan[{node_id}] ranking_top必须引用前置base产品排名")
|
||||
if (not isinstance(stage, str) or stage not in STAGES
|
||||
combined_source = stage == 'overall' and not source['stages'] and metric == 'scrapWeight'
|
||||
if (not isinstance(stage, str) or stage not in STAGES and not combined_source
|
||||
or not isinstance(metric, str) or metric not in WEIGHTS or type(count) is not int
|
||||
or not 1 <= count <= 10 or count > source["limit"]):
|
||||
raise ValueError(f"queryPlan[{node_id}] ranking_top阶段、指标或count无效")
|
||||
if stage not in source["stages"] or metric not in source["fields"]:
|
||||
if stage not in source["stages"] and not combined_source or metric not in source["fields"]:
|
||||
raise ValueError(f"queryPlan[{node_id}] ranking_top只能选择源排名已查询的阶段和指标")
|
||||
selector = {"kind": kind, "sourceNodeId": source_id, "stage": stage,
|
||||
"metric": metric, "count": count}
|
||||
@@ -219,7 +220,7 @@ def normalize_query_plan(value, *, root_task, root_value=None, context=None):
|
||||
trusted = [item for item in available_rankings if isinstance(item, dict)
|
||||
and item.get("queryId") == query_id and item.get("stage") == stage
|
||||
and item.get("metric") == metric]
|
||||
if (not isinstance(query_id, str) or not query_id or not isinstance(stage, str) or stage not in STAGES
|
||||
if (not isinstance(query_id, str) or not query_id or not isinstance(stage, str) or stage not in STAGES | {'overall'}
|
||||
or not isinstance(metric, str) or metric not in WEIGHTS
|
||||
or len(trusted) != 1 or not isinstance(ranks, list) or not 1 <= len(ranks) <= 10
|
||||
or any(type(rank) is not int or not 1 <= rank <= 10 for rank in ranks)
|
||||
@@ -291,9 +292,9 @@ def normalize_query_plan(value, *, root_task, root_value=None, context=None):
|
||||
raise ValueError(f'queryPlan[{node_id}] 合格率排序不能改成重量指标')
|
||||
if sort in ('scrap_delta','current_scrap') and 'scrapWeight' not in fields:
|
||||
raise ValueError(f'queryPlan[{node_id}] 报废重量排序必须保留scrapWeight')
|
||||
from nao_changes import diagnostic_intent
|
||||
from nao_changes import diagnostic_intent, performance_intent
|
||||
if (dimension=='product' and sort in ('rate_drop','current_rate')
|
||||
and diagnostic_intent(root_task.get('question'))
|
||||
and (diagnostic_intent(root_task.get('question')) or performance_intent(root_task.get('question')))
|
||||
and not re.search(r'按.{0,8}(?:率|降幅).{0,6}(?:排|排序)|降幅.{0,4}(?:最大|最多)|率.{0,4}最低',root_task.get('question',''))):
|
||||
raise ValueError('原因定位不能只按产品率降幅或本期低率筛选小批量:使用scrap_delta及fields=[rate,totalWeight,scrapWeight],结合两期投入和报废增量找线索;率排名只有用户明确要求时才单独使用')
|
||||
node.update(dimension=dimension, limit=limit, sort=sort)
|
||||
@@ -301,7 +302,8 @@ def normalize_query_plan(value, *, root_task, root_value=None, context=None):
|
||||
raise ValueError(f'queryPlan[{node_id}] sort仅用于changes')
|
||||
elif purpose == "ranking":
|
||||
dimension, limit = raw.get("dimension"), raw.get("limit")
|
||||
if not isinstance(dimension, str) or dimension not in SELECTOR_DIMENSIONS or not fields or set(fields) - WEIGHTS or not stages:
|
||||
combined = not stages and 'scrapWeight' in fields and set(fields) <= {'rate', 'scrapWeight'}
|
||||
if not isinstance(dimension, str) or dimension not in SELECTOR_DIMENSIONS or not fields or not (combined or stages and not set(fields) - WEIGHTS):
|
||||
raise ValueError(f"queryPlan[{node_id}] ranking必须指定维度、重量字段和阶段")
|
||||
if type(limit) is not int or not 1 <= limit <= 10:
|
||||
raise ValueError(f"queryPlan[{node_id}].limit须为1到10")
|
||||
@@ -328,7 +330,8 @@ def normalize_query_plan(value, *, root_task, root_value=None, context=None):
|
||||
raise ValueError(f"queryPlan[{node_id}]仅ranking接受dimension/limit")
|
||||
elif "defect" in raw or "category" in raw:
|
||||
raise ValueError(f"queryPlan[{node_id}]仅defects节点接受defect/category")
|
||||
if not is_raw and purpose != 'changes' and not stages and fields != ["rate"]:
|
||||
if not is_raw and purpose != 'changes' and not stages and fields != ["rate"] and not (
|
||||
purpose == 'ranking' and 'scrapWeight' in fields and set(fields) <= {'rate', 'scrapWeight'}):
|
||||
raise ValueError(f"queryPlan[{node_id}]仅综合合格率可省略stages")
|
||||
if purpose not in ("metrics", "source", "records", "defects", "changes") and comparison_required:
|
||||
raise ValueError(f"queryPlan[{node_id}]仅metrics/source/records/defects节点支持期间比较")
|
||||
|
||||
Reference in New Issue
Block a user