|
@@ -1257,14 +1257,16 @@ class HotContentRepository:
|
|
|
demand_name,
|
|
demand_name,
|
|
|
demand_type,
|
|
demand_type,
|
|
|
record_id,
|
|
record_id,
|
|
|
- weight
|
|
|
|
|
|
|
+ weight,
|
|
|
|
|
+ extend
|
|
|
)
|
|
)
|
|
|
- VALUES (%s, %s, %s, %s, %s, %s, %s)
|
|
|
|
|
|
|
+ VALUES (%s, %s, %s, %s, %s, %s, %s, %s)
|
|
|
ON DUPLICATE KEY UPDATE
|
|
ON DUPLICATE KEY UPDATE
|
|
|
demand_name = VALUES(demand_name),
|
|
demand_name = VALUES(demand_name),
|
|
|
demand_type = VALUES(demand_type),
|
|
demand_type = VALUES(demand_type),
|
|
|
record_id = VALUES(record_id),
|
|
record_id = VALUES(record_id),
|
|
|
weight = VALUES(weight),
|
|
weight = VALUES(weight),
|
|
|
|
|
+ extend = VALUES(extend),
|
|
|
synced_at = CURRENT_TIMESTAMP
|
|
synced_at = CURRENT_TIMESTAMP
|
|
|
"""
|
|
"""
|
|
|
insert_rows = [
|
|
insert_rows = [
|
|
@@ -1276,6 +1278,7 @@ class HotContentRepository:
|
|
|
str(item.get("demand_type") or ""),
|
|
str(item.get("demand_type") or ""),
|
|
|
int(item.get("record_id") or 0),
|
|
int(item.get("record_id") or 0),
|
|
|
float(item["weight"]) if item.get("weight") is not None else None,
|
|
float(item["weight"]) if item.get("weight") is not None else None,
|
|
|
|
|
+ str(item.get("extend") or "{}"),
|
|
|
)
|
|
)
|
|
|
for item in rows
|
|
for item in rows
|
|
|
if str(item.get("demand_id") or "").strip()
|
|
if str(item.get("demand_id") or "").strip()
|
|
@@ -1304,6 +1307,26 @@ class HotContentRepository:
|
|
|
"""
|
|
"""
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ def _ensure_odps_sync_log_extend_column(self, cursor: Any) -> None:
|
|
|
|
|
+ cursor.execute(
|
|
|
|
|
+ """
|
|
|
|
|
+ SELECT COUNT(*) AS cnt
|
|
|
|
|
+ FROM information_schema.COLUMNS
|
|
|
|
|
+ WHERE TABLE_SCHEMA = DATABASE()
|
|
|
|
|
+ AND TABLE_NAME = 'hot_content_odps_sync_log'
|
|
|
|
|
+ AND COLUMN_NAME = 'extend'
|
|
|
|
|
+ """,
|
|
|
|
|
+ )
|
|
|
|
|
+ if int((cursor.fetchone() or {}).get("cnt") or 0) == 0:
|
|
|
|
|
+ cursor.execute(
|
|
|
|
|
+ """
|
|
|
|
|
+ ALTER TABLE hot_content_odps_sync_log
|
|
|
|
|
+ ADD COLUMN extend TEXT NULL DEFAULT NULL
|
|
|
|
|
+ COMMENT 'ODPS extend 扩展字段 JSON'
|
|
|
|
|
+ AFTER weight
|
|
|
|
|
+ """
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
def list_wxindex_word_scores(self, name: str) -> list[dict[str, Any]]:
|
|
def list_wxindex_word_scores(self, name: str) -> list[dict[str, Any]]:
|
|
|
word = str(name or "").strip()
|
|
word = str(name or "").strip()
|
|
|
if not word:
|
|
if not word:
|
|
@@ -2529,6 +2552,7 @@ class HotContentRepository:
|
|
|
demand_type VARCHAR(32) NOT NULL DEFAULT '' COMMENT '特征点/短语',
|
|
demand_type VARCHAR(32) NOT NULL DEFAULT '' COMMENT '特征点/短语',
|
|
|
record_id BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '来源 hot_content_records.id',
|
|
record_id BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '来源 hot_content_records.id',
|
|
|
weight DOUBLE NULL DEFAULT NULL COMMENT 'ODPS 需求权重(记录 wxindex 最高分 / 1000000)',
|
|
weight DOUBLE NULL DEFAULT NULL COMMENT 'ODPS 需求权重(记录 wxindex 最高分 / 1000000)',
|
|
|
|
|
+ extend TEXT NULL DEFAULT NULL COMMENT 'ODPS extend 扩展字段 JSON',
|
|
|
synced_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '写入 ODPS 时间',
|
|
synced_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '写入 ODPS 时间',
|
|
|
PRIMARY KEY (id),
|
|
PRIMARY KEY (id),
|
|
|
UNIQUE KEY uk_odps_sync (partition_dt, strategy, demand_id),
|
|
UNIQUE KEY uk_odps_sync (partition_dt, strategy, demand_id),
|
|
@@ -2539,3 +2563,4 @@ class HotContentRepository:
|
|
|
with self.conn.cursor() as cursor:
|
|
with self.conn.cursor() as cursor:
|
|
|
cursor.execute(sql)
|
|
cursor.execute(sql)
|
|
|
self._ensure_odps_sync_log_weight_column(cursor)
|
|
self._ensure_odps_sync_log_weight_column(cursor)
|
|
|
|
|
+ self._ensure_odps_sync_log_extend_column(cursor)
|