feat: 添加唯一计数去重功能,优化福袋相关统计逻辑
This commit is contained in:
1 parent
90b7daa84e
commit
d81eea63c9
10 files changed
+333
-54
No files matched your search
+30
-1
@@ -156,7 +156,7 @@ class Runner:
|
||||
"""
|
||||
try:
|
||||
with self._lock:
|
||||
content = (self._fudai_last.get("content") or "")
|
||||
content = self._fudai_last.get("content") or ""
|
||||
prize = str(self._fudai_last.get("prize_value_yuan") or "")
|
||||
countdown = str(self._fudai_last.get("countdown") or "")
|
||||
key = f"{content}|{prize}|{countdown}"
|
||||
@@ -214,6 +214,14 @@ class Runner:
|
||||
if content_extracted:
|
||||
self._inc("fudai_seen")
|
||||
self._record_event("fudai_seen", self._snapshot_fudai())
|
||||
# 唯一口径:基于 snapshot 的 content/prize/countdown 去重
|
||||
try:
|
||||
key = self._make_unique_key()
|
||||
if key and key not in self._unique_keys_seen:
|
||||
self._unique_keys_seen.add(key)
|
||||
self._inc("fudai_seen_unique")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 参与人数:支持多种格式
|
||||
m = re.search(r"(?:字段_)?参与人数[=:]?\s*(\d+)", s)
|
||||
@@ -265,11 +273,25 @@ class Runner:
|
||||
if "点击打开福袋详情" in s or ("[流程]" in s and "检测到福袋图标并点击" in s):
|
||||
self._inc("fudai_open_detail")
|
||||
self._record_event("fudai_open_detail", self._snapshot_fudai())
|
||||
try:
|
||||
key = self._make_unique_key()
|
||||
if key and key not in self._unique_keys_open:
|
||||
self._unique_keys_open.add(key)
|
||||
self._inc("fudai_open_detail_unique")
|
||||
except Exception:
|
||||
pass
|
||||
if "点击参与抽奖" in s or (
|
||||
"[参与]" in s and ("动作=点击参与" in s or "动作=参与" in s)
|
||||
):
|
||||
self._inc("fudai_click_attend")
|
||||
self._record_event("fudai_click_attend", self._snapshot_fudai())
|
||||
try:
|
||||
key = self._make_unique_key()
|
||||
if key and key not in self._unique_keys_attend:
|
||||
self._unique_keys_attend.add(key)
|
||||
self._inc("fudai_click_attend_unique")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 参与成功/已参与:支持更多格式
|
||||
if (
|
||||
@@ -285,6 +307,13 @@ class Runner:
|
||||
):
|
||||
self._inc("fudai_attend_ok")
|
||||
self._record_event("fudai_attend_ok", self._snapshot_fudai())
|
||||
try:
|
||||
key = self._make_unique_key()
|
||||
if key and key not in self._unique_keys_attend:
|
||||
self._unique_keys_attend.add(key)
|
||||
self._inc("fudai_attend_ok_unique")
|
||||
except Exception:
|
||||
pass
|
||||
if "参与抽奖失败" in s or ("[参与]" in s and "结果=失败" in s):
|
||||
self._inc("fudai_attend_fail")
|
||||
self._record_event("fudai_attend_fail", self._snapshot_fudai())
|
||||
|
||||
Reference in new issue
Block a user