兜底
This commit is contained in:
+36
-25
@@ -21,6 +21,7 @@ from loguru import logger
|
||||
|
||||
from .cdp_lite import LiteCDP, CDPSession
|
||||
from .manager import BrowserManager
|
||||
from .. import outbox
|
||||
from ..ai import AIClient
|
||||
from ..server_api import ServerAPI
|
||||
|
||||
@@ -427,7 +428,10 @@ class Applicant:
|
||||
def _handle_card(self, card: JobCard, salary_min, salary_max,
|
||||
min_score, delay_range) -> int:
|
||||
try:
|
||||
# 云端去重只认实际投递过的(chat/deliver);
|
||||
# 被跳过的职位不算已投递,下次出现会重新评估
|
||||
if self.server.check_applied(card.job_id):
|
||||
logger.debug(f"已投递过,跳过(不计入跳过数):{card.company} - {card.title}")
|
||||
return 0
|
||||
except Exception:
|
||||
pass
|
||||
@@ -570,40 +574,47 @@ class Applicant:
|
||||
# 服务端上报
|
||||
# ------------------------------------------------------------------
|
||||
def _report_apply(self, card: JobCard, ai_score: int, ai_reason: str):
|
||||
body = {
|
||||
"job_id": card.job_id,
|
||||
"job_title": card.title,
|
||||
"company": card.company,
|
||||
"salary": card.salary or None,
|
||||
"location": card.location,
|
||||
"apply_type": "chat",
|
||||
"ai_score": ai_score,
|
||||
"ai_reason": ai_reason[:255] if ai_reason else None,
|
||||
"jd_text": card.jd_text or None,
|
||||
}
|
||||
# 先落盘兜底,发送成功才删除;失败留后台补发
|
||||
entry_id = outbox.enqueue(self.session_id, body, applied_delta=1)
|
||||
try:
|
||||
self.server.report_application(self.session_id, {
|
||||
"job_id": card.job_id,
|
||||
"job_title": card.title,
|
||||
"company": card.company,
|
||||
"salary": card.salary or None,
|
||||
"location": card.location,
|
||||
"apply_type": "chat",
|
||||
"ai_score": ai_score,
|
||||
"ai_reason": ai_reason[:255] if ai_reason else None,
|
||||
"jd_text": card.jd_text or None,
|
||||
})
|
||||
self.server.report_application(self.session_id, body)
|
||||
outbox.ack(entry_id)
|
||||
self.server.update_session_stats(self.session_id, applied_delta=1, skipped_delta=0)
|
||||
self.stats["applied"] += 1
|
||||
logger.success(f"[{self.stats['applied']}] 投递成功:{card.company} - {card.title}")
|
||||
except Exception as e:
|
||||
logger.warning(f"上报投递记录失败:{e}")
|
||||
logger.warning(f"上报投递记录失败,已入本地 outbox 后台补发:{e}")
|
||||
|
||||
def _report_skip(self, card: JobCard, reason: str, ai_score: int = -1, ai_reason: str = ""):
|
||||
body = {
|
||||
"job_id": card.job_id,
|
||||
"job_title": card.title,
|
||||
"company": card.company,
|
||||
"salary": card.salary or None,
|
||||
"location": card.location,
|
||||
"apply_type": "skipped",
|
||||
"ai_score": ai_score,
|
||||
"ai_reason": ai_reason[:255] if ai_reason else None,
|
||||
"skip_reason": reason,
|
||||
"jd_text": card.jd_text or None,
|
||||
}
|
||||
entry_id = outbox.enqueue(self.session_id, body, skipped_delta=1)
|
||||
try:
|
||||
self.server.report_application(self.session_id, {
|
||||
"job_id": card.job_id,
|
||||
"job_title": card.title,
|
||||
"company": card.company,
|
||||
"salary": card.salary or None,
|
||||
"location": card.location,
|
||||
"apply_type": "skipped",
|
||||
"ai_score": ai_score,
|
||||
"ai_reason": ai_reason[:255] if ai_reason else None,
|
||||
"skip_reason": reason,
|
||||
"jd_text": card.jd_text or None,
|
||||
})
|
||||
self.server.report_application(self.session_id, body)
|
||||
outbox.ack(entry_id)
|
||||
self.server.update_session_stats(self.session_id, applied_delta=0, skipped_delta=1)
|
||||
self.stats["skipped"] += 1
|
||||
logger.info(f"跳过({reason}):{card.company} - {card.title}")
|
||||
except Exception as e:
|
||||
logger.debug(f"上报跳过记录失败:{e}")
|
||||
logger.debug(f"上报跳过记录失败,已入本地 outbox 后台补发:{e}")
|
||||
|
||||
Reference in New Issue
Block a user