IS READ UPDATE
parent
36be406f92
commit
09fdb39109
|
|
@ -1,4 +1,4 @@
|
|||
from fastapi import APIRouter,Depends
|
||||
from fastapi import APIRouter,Depends,Query
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi import HTTPException
|
||||
from db_setup import get_session
|
||||
|
|
@ -49,6 +49,22 @@ async def cv_upload(
|
|||
raise HTTPException(status_code=500,detail=str(e))
|
||||
|
||||
|
||||
@router.post("/candidate/inbox-match")
|
||||
async def candidate_inbox_match(
|
||||
inbox_message_id: str = Query(...),
|
||||
current_user: dict = Depends(require_permission(PermissionTag.CANDIDATES_EDIT)),
|
||||
session: AsyncSession = Depends(get_session),
|
||||
):
|
||||
try:
|
||||
service=FileRead(session=session)
|
||||
data=await service.match_inbox_cv(inbox_message_id)
|
||||
return JSONResponse(content={"data":data,"status_code":200})
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500,detail=str(e))
|
||||
|
||||
|
||||
@router.post("/job/post-job")
|
||||
async def post_job(
|
||||
payload: JobPostCreate,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
import os,logging,io
|
||||
from datetime import datetime,timezone
|
||||
from fastapi import HTTPException
|
||||
from pypdf import PdfReader
|
||||
from sqlalchemy import select
|
||||
from inbox.models import Inbox_Messages
|
||||
from job.candidate.plugins import normalize_spaced_text
|
||||
|
||||
class FileRead:
|
||||
|
|
@ -26,7 +28,41 @@ class FileRead:
|
|||
raise
|
||||
except Exception as e:
|
||||
raise HTTPException(400, str(e))
|
||||
|
||||
async def match_inbox_cv(self,inbox_message_id):
|
||||
from inbox.plugins import resolve_attachment_path
|
||||
from inbox.tasks import match_inbox_message
|
||||
|
||||
row=await Inbox_Messages.get_inbox_message_by_id(self.session,inbox_message_id)
|
||||
if not row:
|
||||
raise HTTPException(status_code=404,detail="Message not found")
|
||||
if not row.attachment or not row.file_path:
|
||||
raise HTTPException(status_code=400,detail="your file isnt in the system")
|
||||
|
||||
found=None
|
||||
for path_str in (p.strip() for p in row.file_path.split(",") if p.strip()):
|
||||
path=resolve_attachment_path(path_str)
|
||||
if path.is_file():
|
||||
found=path
|
||||
break
|
||||
if found is None:
|
||||
raise HTTPException(status_code=400,detail="your file isnt in the system")
|
||||
|
||||
created_at=datetime.now(timezone.utc).isoformat()
|
||||
task=await match_inbox_message.kicker().with_labels(
|
||||
created_at=created_at,
|
||||
correlation_id=str(row.id),
|
||||
queue="inbox",
|
||||
).kiq(str(row.id),force=True)
|
||||
|
||||
file_name=(row.file_name or "").split(",")[0].strip() or found.name
|
||||
return {
|
||||
"queued":True,
|
||||
"inbox_message_id":str(row.id),
|
||||
"file_name":file_name,
|
||||
"task_id":task.task_id,
|
||||
}
|
||||
# async def get_intention(self,input):
|
||||
# try:
|
||||
# get_subject=Inbox_Messages.candidate_x_inbox(self.session,self.candidate_id)
|
||||
# get_file=
|
||||
# get_file=
|
||||
|
|
|
|||
Loading…
Reference in New Issue