33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
from app.tasks.worker import celery_app
|
|
|
|
|
|
@celery_app.task(bind=True)
|
|
def auto_classify_task(self, project_id: int, source_ids: list = None):
|
|
"""
|
|
Async task to run automatic classification on metadata.
|
|
Phase 1 placeholder.
|
|
"""
|
|
from app.core.database import SessionLocal
|
|
from app.models.project import ClassificationProject, ClassificationResult, ResultStatus
|
|
from app.models.classification import RecognitionRule
|
|
from app.models.metadata import DataColumn
|
|
|
|
db = SessionLocal()
|
|
try:
|
|
project = db.query(ClassificationProject).filter(ClassificationProject.id == project_id).first()
|
|
if not project:
|
|
return {"status": "failed", "reason": "project not found"}
|
|
|
|
# Update project status
|
|
project.status = "scanning"
|
|
db.commit()
|
|
|
|
rules = db.query(RecognitionRule).filter(RecognitionRule.is_active == True).all()
|
|
# TODO: implement rule matching logic in Phase 2
|
|
|
|
project.status = "assigning"
|
|
db.commit()
|
|
return {"status": "completed", "project_id": project_id, "matched": 0}
|
|
finally:
|
|
db.close()
|