Spaces:
Sleeping
Sleeping
| from datetime import date, datetime | |
| def _days_since(date_str: str | None) -> float: | |
| if not date_str: | |
| return 999.0 | |
| for fmt in ("%Y-%m-%d", "%Y-%m", "%Y"): | |
| try: | |
| d = datetime.strptime(date_str, fmt).date() | |
| return float(max(0, (date.today() - d).days)) | |
| except ValueError: | |
| continue | |
| return 999.0 | |
| def score(candidate: dict) -> float: | |
| signals = candidate.get("redrob_signals", {}) or {} | |
| days_inactive = _days_since(signals.get("last_active_date")) | |
| recency = max(0.0, 1.0 - days_inactive / 180.0) | |
| response_rate = float(signals.get("recruiter_response_rate") or 0.0) | |
| open_to_work = 1.0 if signals.get("open_to_work_flag") else 0.0 | |
| if open_to_work and days_inactive < 7: | |
| response_rate = max(response_rate, 0.3) | |
| return float(min(1.0, 0.4 * recency + 0.4 * response_rate + 0.2 * open_to_work)) | |