ProjectTech4DevAI / ProjectTech4DevAI/kaapi-backend
Async Job: Foreign Key Association for Project and Organization
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18
- Forks
- 10
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 14
Description
Describe the current behavior
Async "Job" database model does not have project_id and organization_id FK relation
Describe the enhancement you'd like
Add these relations or use batch_job table for both the celery async job and other batch job status
Why is this enhancement needed?
From a maintainability perspective
Additional context
class Job(SQLModel, table=True):
"""Database model for tracking async jobs."""
__tablename__ = "job"
id: UUID = Field(
default_factory=uuid4,
primary_key=True,
sa_column_kwargs={"comment": "Unique identifier for the job"},
)
task_id: str | None = Field(
nullable=True,
description="Celery task ID returned when job is queued.",
sa_column_kwargs={"comment": "Celery task ID returned when job is queued"},
)
trace_id: str | None = Field(
default=None,
description="Tracing ID for correlating logs and traces.",
sa_column_kwargs={"comment": "Tracing ID for correlating logs and traces"},
)
error_message: str | None = Field(
default=None,
description="Error details if the job fails.",
sa_column_kwargs={"comment": "Error details if the job fails"},
)
status: JobStatus = Field(
default=JobStatus.PENDING,
description="Current state of the job.",
sa_column_kwargs={
"comment": "Current state of the job (PENDING, PROCESSING, SUCCESS, FAILED)"
},
)
job_type: JobType = Field(
description="Type of job being executed (e.g., response, ingestion).",
sa_column_kwargs={
"comment": "Type of job being executed (e.g., RESPONSE, LLM_API)"
},
)
# Timestamps
created_at: datetime = Field(
default_factory=now,
sa_column_kwargs={"comment": "Timestamp when the job was created"},
)
updated_at: datetime = Field(
default_factory=now,
sa_column_kwargs={"comment": "Timestamp when the job was last updated"},
)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the SQLModel Job definition and the existing project, organization, and batch_job models or tables. Compare whether the async job should receive both foreign-key relationships or share batch_job, then inspect the related schema and migration conventions. Done means the chosen design maintains the required associations without duplicating job status models.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100