main
py 23 lines 793 Bytes
Raw
1 from datetime import datetime
2 from typing import Optional
3
4 from pydantic import BaseModel
5 from sqlmodel import Field
6 from sqlmodel import SQLModel
7
8
9 class JobMetadata(SQLModel, table=True):
10 __tablename__ = "scheduled_job_metadata"
11 id: Optional[int] = Field(default=None, primary_key=True)
12 job_id: str = Field(index=True) # Corresponds to the APScheduler job ID
13 last_success: Optional[datetime] = None
14 time_interval: int # The frequency of the job in minutes
15 extra_data: Optional[str] = None # Extra data for the job
16 enabled: bool # Indicates if the job is active or not
17 job_description: Optional[str] = Field(max_length=1024) # Description of the job
18
19
20 class CreateSchedulerRequest(BaseModel):
21 function_name: str
22 job_id: str
23 time_interval: int