基本完成
This commit is contained in:
@@ -98,6 +98,40 @@ def today_count(
|
||||
return {"count": count}
|
||||
|
||||
|
||||
@router.get("/today", response_model=dict)
|
||||
def today_applications(
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""当天(北京时间)全部投递/跳过记录,供独立展示前端使用"""
|
||||
now_cn = datetime.utcnow() + timedelta(hours=8)
|
||||
start_utc = now_cn.replace(hour=0, minute=0, second=0, microsecond=0) - timedelta(hours=8)
|
||||
rows = db.query(JobApplication).filter(
|
||||
JobApplication.user_id == current_user.id,
|
||||
JobApplication.applied_at >= start_utc,
|
||||
).order_by(JobApplication.applied_at.desc()).all()
|
||||
|
||||
applied = skipped = 0
|
||||
items = []
|
||||
for r in rows:
|
||||
if r.apply_type in ("chat", "deliver"):
|
||||
applied += 1
|
||||
elif r.apply_type == "skipped":
|
||||
skipped += 1
|
||||
items.append({
|
||||
"job_title": r.job_title,
|
||||
"company": r.company,
|
||||
"salary": r.salary,
|
||||
"location": r.location,
|
||||
"apply_type": r.apply_type,
|
||||
"ai_score": r.ai_score,
|
||||
"ai_reason": r.ai_reason,
|
||||
"skip_reason": r.skip_reason,
|
||||
"applied_at": (r.applied_at + timedelta(hours=8)).strftime("%H:%M:%S"),
|
||||
})
|
||||
return {"applied": applied, "skipped": skipped, "total": len(rows), "items": items}
|
||||
|
||||
|
||||
@router.get("/history", response_model=list[ApplicationOut])
|
||||
def list_applications(
|
||||
apply_type: Optional[str] = Query(None, description="过滤投递类型"),
|
||||
|
||||
Reference in New Issue
Block a user