|
|
@@ -193,6 +193,8 @@ def append_wxindex_keyword_rows(
|
|
|
return
|
|
|
|
|
|
word_row = _resolve_word_row(keyword, word_lookup=word_lookup, match_result=match_result)
|
|
|
+ if not extract_matched_demand_names(word_row):
|
|
|
+ return
|
|
|
categories = ordered_point_categories(word_to_categories.get(keyword, set()))
|
|
|
if categories:
|
|
|
for category in categories:
|
|
|
@@ -214,7 +216,9 @@ def build_demand_export_rows(
|
|
|
words_rows = []
|
|
|
|
|
|
contribution_source = contribution_points if isinstance(contribution_points, dict) else match_result
|
|
|
- points = contribution_source.get("点列表") or []
|
|
|
+ points = match_result.get("点列表") or []
|
|
|
+ if not isinstance(points, list) or not points:
|
|
|
+ points = contribution_source.get("点列表") or []
|
|
|
if not isinstance(points, list):
|
|
|
points = []
|
|
|
|
|
|
@@ -225,6 +229,8 @@ def build_demand_export_rows(
|
|
|
categories = ordered_point_categories(word_to_categories.get(word_text, set()))
|
|
|
if not categories:
|
|
|
continue
|
|
|
+ if not extract_matched_demand_names(word_row):
|
|
|
+ continue
|
|
|
for category in categories:
|
|
|
export_rows.append(_build_word_export_row(word_text, word_row, category))
|
|
|
|
|
|
@@ -235,12 +241,15 @@ def build_demand_export_rows(
|
|
|
category = str(point_item.get("来源") or "").strip()
|
|
|
if not point_text or category not in POINT_CATEGORIES:
|
|
|
continue
|
|
|
+ matched_demand = extract_point_matched_demand_names(point_item, word_lookup)
|
|
|
+ if not matched_demand:
|
|
|
+ continue
|
|
|
export_rows.append(
|
|
|
{
|
|
|
"item_type": ITEM_TYPE_PHRASE,
|
|
|
"item_text": point_text,
|
|
|
"point_category": category,
|
|
|
- "matched_demand": extract_point_matched_demand_names(point_item, word_lookup),
|
|
|
+ "matched_demand": matched_demand,
|
|
|
"contribution_score": None,
|
|
|
}
|
|
|
)
|
|
|
@@ -281,17 +290,10 @@ def attach_wxindex_metadata(
|
|
|
wxindex_keyword = get_wxindex_keyword(trend_json)
|
|
|
rows: list[dict[str, Any]] = []
|
|
|
for row in export_rows:
|
|
|
- item_type = str(row.get("item_type") or "")
|
|
|
- item_text = str(row.get("item_text") or "").strip()
|
|
|
matched_demand = str(row.get("matched_demand") or "").strip()
|
|
|
has_record_wxindex = latest_score is not None
|
|
|
- is_wxindex_keyword = (
|
|
|
- item_type == ITEM_TYPE_ELEMENT and wxindex_keyword and item_text == wxindex_keyword
|
|
|
- )
|
|
|
|
|
|
- if has_record_wxindex and (
|
|
|
- matched_demand or item_type == ITEM_TYPE_PHRASE or is_wxindex_keyword
|
|
|
- ):
|
|
|
+ if has_record_wxindex and matched_demand:
|
|
|
wxindex_score = float(latest_score)
|
|
|
wxindex_trend_value = trend
|
|
|
else:
|
|
|
@@ -395,6 +397,14 @@ def export_existing_records(
|
|
|
)
|
|
|
if not export_rows:
|
|
|
summary["no_export_rows"] += 1
|
|
|
+ if not dry_run:
|
|
|
+ repository.replace_demand_export_rows(
|
|
|
+ record_id=record_id,
|
|
|
+ source=str(row.get("source") or ""),
|
|
|
+ hot_title=str(row.get("title") or ""),
|
|
|
+ article_title=str(row.get("article_title") or ""),
|
|
|
+ rows=[],
|
|
|
+ )
|
|
|
continue
|
|
|
|
|
|
if verbose or dry_run:
|