init
This commit is contained in:
@@ -161,20 +161,25 @@ class Applicant:
|
|||||||
|
|
||||||
self.stats["current"] = f"评估:{card.company} - {card.title}"
|
self.stats["current"] = f"评估:{card.company} - {card.title}"
|
||||||
|
|
||||||
# 2. AI 匹配度评分
|
# 2. 抓取 JD 详情(供 AI 评分与归档记录,统一前置)
|
||||||
|
if not card.jd_text:
|
||||||
|
card.jd_text = self._fetch_jd_detail(card)
|
||||||
|
|
||||||
|
# 3. AI 匹配度评分
|
||||||
ai_score, ai_reason = -1, ""
|
ai_score, ai_reason = -1, ""
|
||||||
if self.ai and self.ai.available() and self.primary_resume_content:
|
if self.ai and self.ai.available() and self.primary_resume_content:
|
||||||
jd = card.jd_text or self._fetch_jd_detail(card)
|
result = self.ai.score_job(card.jd_text, self.primary_resume_content)
|
||||||
result = self.ai.score_job(jd, self.primary_resume_content)
|
|
||||||
ai_score, ai_reason = result.score, result.reason
|
ai_score, ai_reason = result.score, result.reason
|
||||||
if not result.is_worth_applying(min_score):
|
if not result.is_worth_applying(min_score):
|
||||||
self._report_skip(card, f"AI 评分低({ai_score})", ai_score, ai_reason)
|
self._report_skip(card, f"AI 评分低({ai_score})", ai_score, ai_reason)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
# 3. 执行投递
|
# 4. 执行投递
|
||||||
success, apply_type = self._apply(card, greeting)
|
success, apply_type = self._apply(card, greeting)
|
||||||
if success:
|
if success:
|
||||||
self._report_apply(card, apply_type, ai_score, ai_reason)
|
# 打招呼语仅 chat 方式实际发送过,才归档
|
||||||
|
greeting_used = greeting if (apply_type == "chat" and greeting) else None
|
||||||
|
self._report_apply(card, apply_type, ai_score, ai_reason, greeting_used)
|
||||||
self._sleep(*delay_range)
|
self._sleep(*delay_range)
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
@@ -182,7 +187,8 @@ class Applicant:
|
|||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# 服务端上报
|
# 服务端上报
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
def _report_apply(self, card: JobCard, apply_type: str, ai_score: int, ai_reason: str):
|
def _report_apply(self, card: JobCard, apply_type: str, ai_score: int, ai_reason: str,
|
||||||
|
greeting: str | None = None):
|
||||||
try:
|
try:
|
||||||
self.server.report_application(self.session_id, {
|
self.server.report_application(self.session_id, {
|
||||||
"job_id": card.job_id,
|
"job_id": card.job_id,
|
||||||
@@ -193,6 +199,8 @@ class Applicant:
|
|||||||
"apply_type": apply_type,
|
"apply_type": apply_type,
|
||||||
"ai_score": ai_score,
|
"ai_score": ai_score,
|
||||||
"ai_reason": ai_reason[:255] if ai_reason else None,
|
"ai_reason": ai_reason[:255] if ai_reason else None,
|
||||||
|
"jd_text": card.jd_text or None,
|
||||||
|
"greeting": greeting,
|
||||||
})
|
})
|
||||||
self.server.update_session_stats(self.session_id, applied_delta=1, skipped_delta=0)
|
self.server.update_session_stats(self.session_id, applied_delta=1, skipped_delta=0)
|
||||||
self.stats["applied"] += 1
|
self.stats["applied"] += 1
|
||||||
@@ -211,6 +219,7 @@ class Applicant:
|
|||||||
"ai_score": ai_score,
|
"ai_score": ai_score,
|
||||||
"ai_reason": ai_reason[:255] if ai_reason else None,
|
"ai_reason": ai_reason[:255] if ai_reason else None,
|
||||||
"skip_reason": reason,
|
"skip_reason": reason,
|
||||||
|
"jd_text": card.jd_text or None,
|
||||||
})
|
})
|
||||||
self.server.update_session_stats(self.session_id, applied_delta=0, skipped_delta=1)
|
self.server.update_session_stats(self.session_id, applied_delta=0, skipped_delta=1)
|
||||||
self.stats["skipped"] += 1
|
self.stats["skipped"] += 1
|
||||||
|
|||||||
@@ -354,7 +354,7 @@ async function loadHistory() {
|
|||||||
`;
|
`;
|
||||||
$('historyBody').innerHTML = history.map(h => `
|
$('historyBody').innerHTML = history.map(h => `
|
||||||
<tr>
|
<tr>
|
||||||
<td>${escapeHtml(h.job_title || '-')}</td>
|
<td title="${escapeHtml(recordDetail(h))}">${escapeHtml(h.job_title || '-')}</td>
|
||||||
<td>${escapeHtml(h.company || '-')}</td>
|
<td>${escapeHtml(h.company || '-')}</td>
|
||||||
<td>${escapeHtml(h.salary || '-')}</td>
|
<td>${escapeHtml(h.salary || '-')}</td>
|
||||||
<td><span class="tag ${safeType(h.apply_type)}">${typeLabel(h.apply_type)}</span></td>
|
<td><span class="tag ${safeType(h.apply_type)}">${typeLabel(h.apply_type)}</span></td>
|
||||||
@@ -368,6 +368,14 @@ async function loadHistory() {
|
|||||||
function typeLabel(t) {
|
function typeLabel(t) {
|
||||||
return { chat: '沟通', deliver: '投递', skipped: '跳过' }[t] || t;
|
return { chat: '沟通', deliver: '投递', skipped: '跳过' }[t] || t;
|
||||||
}
|
}
|
||||||
|
// 悬停详情:JD 摘要 + 打招呼语(用于 title 属性)
|
||||||
|
function recordDetail(h) {
|
||||||
|
const parts = [];
|
||||||
|
if (h.greeting) parts.push(`【打招呼语】${h.greeting}`);
|
||||||
|
if (h.jd_text) parts.push(`【JD】${h.jd_text.substring(0, 300)}${h.jd_text.length > 300 ? '...' : ''}`);
|
||||||
|
if (h.skip_reason) parts.push(`【跳过原因】${h.skip_reason}`);
|
||||||
|
return parts.join('\n\n') || '暂无详情';
|
||||||
|
}
|
||||||
// apply_type 仅允许白名单值用作 CSS class,防止注入
|
// apply_type 仅允许白名单值用作 CSS class,防止注入
|
||||||
function safeType(t) {
|
function safeType(t) {
|
||||||
return ['chat', 'deliver', 'skipped'].includes(t) ? t : 'skipped';
|
return ['chat', 'deliver', 'skipped'].includes(t) ? t : 'skipped';
|
||||||
|
|||||||
@@ -134,6 +134,7 @@
|
|||||||
<!-- Step 5: 投递记录 -->
|
<!-- Step 5: 投递记录 -->
|
||||||
<section class="panel hidden" id="panel-5">
|
<section class="panel hidden" id="panel-5">
|
||||||
<h2>投递记录与统计</h2>
|
<h2>投递记录与统计</h2>
|
||||||
|
<p class="hint">将鼠标悬停在职位名上,可查看归档的 JD 摘要、打招呼语与跳过原因。</p>
|
||||||
<div class="stats-grid" id="statsGrid"></div>
|
<div class="stats-grid" id="statsGrid"></div>
|
||||||
<table class="history-table">
|
<table class="history-table">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -127,6 +127,10 @@ class JobApplication(Base):
|
|||||||
ai_reason = Column(String(255), nullable=True)
|
ai_reason = Column(String(255), nullable=True)
|
||||||
# 跳过原因
|
# 跳过原因
|
||||||
skip_reason = Column(String(255), nullable=True)
|
skip_reason = Column(String(255), nullable=True)
|
||||||
|
# 职位 JD 全文(投递/跳过时归档,供复盘与面试准备)
|
||||||
|
jd_text = Column(Text, nullable=True)
|
||||||
|
# 实际发送的打招呼语(仅 chat 方式有值)
|
||||||
|
greeting = Column(String(500), nullable=True)
|
||||||
applied_at = Column(DateTime, default=utcnow, nullable=False)
|
applied_at = Column(DateTime, default=utcnow, nullable=False)
|
||||||
|
|
||||||
user = relationship("User", back_populates="applications")
|
user = relationship("User", back_populates="applications")
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ def report_application(
|
|||||||
existing.ai_score = req.ai_score
|
existing.ai_score = req.ai_score
|
||||||
existing.ai_reason = req.ai_reason
|
existing.ai_reason = req.ai_reason
|
||||||
existing.skip_reason = req.skip_reason
|
existing.skip_reason = req.skip_reason
|
||||||
|
if req.jd_text:
|
||||||
|
existing.jd_text = req.jd_text
|
||||||
|
if req.greeting:
|
||||||
|
existing.greeting = req.greeting
|
||||||
if session_id:
|
if session_id:
|
||||||
existing.session_id = session_id
|
existing.session_id = session_id
|
||||||
record = existing
|
record = existing
|
||||||
@@ -53,6 +57,8 @@ def report_application(
|
|||||||
ai_score=req.ai_score,
|
ai_score=req.ai_score,
|
||||||
ai_reason=req.ai_reason,
|
ai_reason=req.ai_reason,
|
||||||
skip_reason=req.skip_reason,
|
skip_reason=req.skip_reason,
|
||||||
|
jd_text=req.jd_text,
|
||||||
|
greeting=req.greeting,
|
||||||
)
|
)
|
||||||
db.add(record)
|
db.add(record)
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ class ApplicationIn(BaseModel):
|
|||||||
ai_score: int = -1
|
ai_score: int = -1
|
||||||
ai_reason: Optional[str] = None
|
ai_reason: Optional[str] = None
|
||||||
skip_reason: Optional[str] = None
|
skip_reason: Optional[str] = None
|
||||||
|
jd_text: Optional[str] = None # JD 全文归档
|
||||||
|
greeting: Optional[str] = None # 实际发送的打招呼语
|
||||||
|
|
||||||
|
|
||||||
class ApplicationOut(BaseModel):
|
class ApplicationOut(BaseModel):
|
||||||
@@ -139,6 +141,8 @@ class ApplicationOut(BaseModel):
|
|||||||
ai_score: int
|
ai_score: int
|
||||||
ai_reason: Optional[str]
|
ai_reason: Optional[str]
|
||||||
skip_reason: Optional[str]
|
skip_reason: Optional[str]
|
||||||
|
jd_text: Optional[str]
|
||||||
|
greeting: Optional[str]
|
||||||
applied_at: datetime
|
applied_at: datetime
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
|
|||||||
Reference in New Issue
Block a user