You've already forked RekomenciBackend
add resume
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
from collections.abc import Sequence
|
||||
from typing import override
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from template_project.adapters.data_gateways.tables import resume_prediction_table
|
||||
from template_project.application.resume.data_gateway import ResumeDataGateway, ResumePredictionDataGateway
|
||||
from template_project.application.resume.entity import Resume, ResumeEmbeddingId, ResumeId, ResumePrediction
|
||||
from template_project.application.resume.errors import ResumeNotFoundError
|
||||
|
||||
|
||||
class DefaultResumeDataGateway(ResumeDataGateway):
|
||||
def __init__(self, session: AsyncSession) -> None:
|
||||
self._session = session
|
||||
|
||||
@override
|
||||
async def get_suitable_resumes(self, embedding_id: ResumeEmbeddingId) -> Sequence[Resume]:
|
||||
raise NotImplementedError
|
||||
|
||||
@override
|
||||
async def load(self, resume_id: ResumeId) -> Resume:
|
||||
resume = await self._session.get(Resume, resume_id)
|
||||
if resume is None:
|
||||
raise ResumeNotFoundError(resume_id=resume_id)
|
||||
|
||||
return resume
|
||||
|
||||
|
||||
class DefaultResumePredictionDataGateway(ResumePredictionDataGateway):
|
||||
def __init__(self, session: AsyncSession) -> None:
|
||||
self._session = session
|
||||
|
||||
@override
|
||||
async def load_by_resume_id(self, resume_id: ResumeId) -> ResumePrediction | None:
|
||||
statement = select(ResumePrediction).where(resume_prediction_table.c.resume_id == resume_id)
|
||||
result = await self._session.execute(statement)
|
||||
return result.scalar()
|
||||
Reference in New Issue
Block a user