Spaces:
Sleeping
Sleeping
Download src/models/audit_log.py from Tahasaif3/Taskflow-App: direct link, hf CLI and curl.
- Browser
- Download file 1.54 kB
-
https://huggingface.co/spaces/Tahasaif3/Taskflow-App/resolve/main/src/models/audit_log.py
- Command line
-
hf download hf://spaces/Tahasaif3/Taskflow-App/src/models/audit_log.py
-
curl -L -o audit_log.py https://huggingface.co/spaces/Tahasaif3/Taskflow-App/resolve/main/src/models/audit_log.py
1.54 kB
| from sqlmodel import SQLModel, Field | |
| from typing import Optional | |
| from datetime import datetime | |
| from sqlalchemy import Column, DateTime, JSON | |
| import uuid | |
| class AuditLogBase(SQLModel): | |
| event_id: str = Field(index=True) # UUID for deduplication | |
| event_type: str = Field(max_length=50) # created|updated|completed|deleted | |
| user_id: str # String user identifier | |
| task_id: int # Reference to the affected task | |
| event_data: dict = Field(sa_column=Column(JSON)) # JSONB field for event data | |
| timestamp: datetime = Field(sa_column=Column(DateTime(timezone=True)), default_factory=lambda: datetime.now(datetime.UTC)) | |
| class AuditLog(AuditLogBase, table=True): | |
| """ | |
| Persistent record of all task events for a user. | |
| Contains id, event_id, event_type, user_id, task_id, event_data (JSONB), and timestamp. | |
| """ | |
| id: Optional[int] = Field(default=None, primary_key=True) | |
| event_id: str = Field(index=True, unique=True) # Unique constraint for deduplication | |
| event_type: str = Field(max_length=50) # created|updated|completed|deleted | |
| user_id: str # String user identifier | |
| task_id: int # Reference to the affected task | |
| event_data: dict = Field(sa_column=Column(JSON)) # JSONB field for event data | |
| timestamp: datetime = Field(sa_column=Column(DateTime(timezone=True)), default_factory=lambda: datetime.now(datetime.UTC)) | |
| class AuditLogCreate(AuditLogBase): | |
| pass | |
| class AuditLogRead(AuditLogBase): | |
| id: int | |
| timestamp: datetime | |
| class Config: | |
| from_attributes = True |