51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
from app.domain.models import Job, MatchRecord, Worker
|
|
from app.domain.schemas import JobCard, MatchBreakdown, MatchResult, Salary, SkillScore, SourceType, WorkerCard
|
|
|
|
|
|
def job_to_card(job: Job) -> JobCard:
|
|
return JobCard(
|
|
job_id=job.id,
|
|
title=job.title,
|
|
category=job.category,
|
|
description=job.description,
|
|
skills=[item.skill_name for item in job.skills],
|
|
city=job.city,
|
|
region=job.region,
|
|
location_detail=job.location_detail,
|
|
start_time=job.start_time,
|
|
duration_hours=job.duration_hours,
|
|
headcount=job.headcount,
|
|
salary=Salary(type=job.salary_type, amount=job.salary_amount, currency=job.salary_currency),
|
|
work_mode=job.work_mode,
|
|
tags=job.tags_json,
|
|
confidence=job.confidence,
|
|
)
|
|
|
|
|
|
def worker_to_card(worker: Worker) -> WorkerCard:
|
|
return WorkerCard(
|
|
worker_id=worker.id,
|
|
name=worker.name,
|
|
description=worker.description,
|
|
skills=[SkillScore(name=item.skill_name, score=item.score) for item in worker.skills],
|
|
cities=worker.cities_json,
|
|
regions=worker.regions_json,
|
|
availability=worker.availability_json,
|
|
experience_tags=worker.experience_tags_json,
|
|
reliability_score=worker.reliability_score,
|
|
profile_completion=worker.profile_completion,
|
|
confidence=worker.confidence,
|
|
)
|
|
|
|
|
|
def match_record_to_schema(match: MatchRecord) -> MatchResult:
|
|
return MatchResult(
|
|
match_id=match.id,
|
|
source_type=SourceType(match.source_type),
|
|
source_id=match.source_id,
|
|
target_id=match.target_id,
|
|
match_score=match.match_score,
|
|
breakdown=MatchBreakdown(**match.breakdown_json),
|
|
reasons=match.reasons_json,
|
|
)
|