|
@@ -532,12 +532,19 @@ def fetch_queries(mode="process"):
|
|
|
|
|
|
|
|
|
|
|
|
|
def fetch_posts(query_id, mode="process"):
|
|
def fetch_posts(query_id, mode="process"):
|
|
|
- """某方向搜索表里某 query 的全部帖子(JSON 列已解析),带 has_process/has_tools 标记。"""
|
|
|
|
|
|
|
+ """列表用:只取列表所需列 + SQL 直取 adopted 标量,**不拉 body/videos/llm_evaluation 大字段**
|
|
|
|
|
+ (llm_evaluation ~1.5MB/帖,旧版 SELECT * 切 tab/选 query 要几十 MB 过远程 RDS,故慢)。
|
|
|
|
|
+ 正文/评分等详情按需走 fetch_post。带 adopted/has_process/has_tools;adopted 口径用
|
|
|
|
|
+ is_adopted_rel(与 is_adopted 完全一致,rel/repro 由 _REL_SQL/_REPRO_SQL 直取标量)。"""
|
|
|
table = _search_table(mode)
|
|
table = _search_table(mode)
|
|
|
conn = _conn()
|
|
conn = _conn()
|
|
|
try:
|
|
try:
|
|
|
with conn.cursor() as cur:
|
|
with conn.cursor() as cur:
|
|
|
- cur.execute(f"""SELECT * FROM {table} WHERE query_id=%s
|
|
|
|
|
|
|
+ cur.execute(f"""SELECT id, query_id, query_text, case_id, platform, channel_content_id,
|
|
|
|
|
+ title, url, content_type, images, like_count, publish_time,
|
|
|
|
|
+ quality_score, quality_grade, found_by, knowledge_type, overall_score,
|
|
|
|
|
+ {_REL_SQL} AS rel, {_REPRO_SQL} AS repro
|
|
|
|
|
+ FROM {table} WHERE query_id=%s
|
|
|
ORDER BY overall_score DESC, id""", (query_id,))
|
|
ORDER BY overall_score DESC, id""", (query_id,))
|
|
|
rows = cur.fetchall()
|
|
rows = cur.fetchall()
|
|
|
cur.execute("SELECT DISTINCT case_id FROM mode_process WHERE query_id=%s", (query_id,))
|
|
cur.execute("SELECT DISTINCT case_id FROM mode_process WHERE query_id=%s", (query_id,))
|
|
@@ -547,12 +554,12 @@ def fetch_posts(query_id, mode="process"):
|
|
|
finally:
|
|
finally:
|
|
|
conn.close()
|
|
conn.close()
|
|
|
for r in rows:
|
|
for r in rows:
|
|
|
- for col in ("images", "videos", "found_by", "knowledge_type", "llm_evaluation"):
|
|
|
|
|
|
|
+ for col in ("images", "found_by", "knowledge_type"):
|
|
|
r[col] = _loads(r[col])
|
|
r[col] = _loads(r[col])
|
|
|
- r["adopted"] = is_adopted(r["overall_score"], r["llm_evaluation"], r["publish_time"])
|
|
|
|
|
|
|
+ r["adopted"] = is_adopted_rel(r["overall_score"], r.pop("rel", None),
|
|
|
|
|
+ r["publish_time"], r.pop("repro", None))
|
|
|
r["has_process"] = r["case_id"] in hp
|
|
r["has_process"] = r["case_id"] in hp
|
|
|
r["has_tools"] = r["case_id"] in ht
|
|
r["has_tools"] = r["case_id"] in ht
|
|
|
- r.pop("created_at", None); r.pop("updated_at", None)
|
|
|
|
|
return rows
|
|
return rows
|
|
|
|
|
|
|
|
|
|
|