mirror of
https://github.com/Cccc-owo/CheckInApp.git
synced 2026-06-17 05:56:29 +00:00
feat(backend): harden task boundaries
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sqlalchemy import Boolean, DateTime, ForeignKey, Index, String, Text
|
||||
from sqlalchemy import Boolean, DateTime, ForeignKey, Index, String, Text, UniqueConstraint
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
@@ -23,6 +23,12 @@ class CheckInTask(Base):
|
||||
index=True,
|
||||
comment="用户 ID",
|
||||
)
|
||||
thread_id: Mapped[str | None] = mapped_column(
|
||||
String(100),
|
||||
index=True,
|
||||
nullable=True,
|
||||
comment="接龙项目 ID",
|
||||
)
|
||||
payload_config: Mapped[str] = mapped_column(
|
||||
Text,
|
||||
default="{}",
|
||||
@@ -57,6 +63,7 @@ class CheckInTask(Base):
|
||||
# 添加索引:加速查询
|
||||
__table_args__ = (
|
||||
Index("ix_task_user_active", "user_id", "is_active"),
|
||||
UniqueConstraint("user_id", "thread_id", name="uq_task_user_thread_id"),
|
||||
Index("ix_task_cron", "cron_expression"), # 加速查询启用了定时打卡的任务
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user