summaryrefslogtreecommitdiff
path: root/src/srht_contrib/models.py
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-11 17:39:21 -0500
committerChristian Cleberg <[email protected]>2026-04-11 17:39:21 -0500
commite1a3233ec2204055faa8dadb18cb2efa12cf0e17 (patch)
treefa6b70671c3f6b71a690e1c99f368616cb1a8e4d /src/srht_contrib/models.py
parentaebe493dcd2b46bf3ae46543f2c0e81625d93ae5 (diff)
downloadhutch-stats-e1a3233ec2204055faa8dadb18cb2efa12cf0e17.tar.gz
hutch-stats-e1a3233ec2204055faa8dadb18cb2efa12cf0e17.tar.bz2
hutch-stats-e1a3233ec2204055faa8dadb18cb2efa12cf0e17.zip
feat: add resumable historical backfill for actor activity
Diffstat (limited to 'src/srht_contrib/models.py')
-rw-r--r--src/srht_contrib/models.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/srht_contrib/models.py b/src/srht_contrib/models.py
index 2f33482..a99a306 100644
--- a/src/srht_contrib/models.py
+++ b/src/srht_contrib/models.py
@@ -71,3 +71,22 @@ class TrackedActor(Base):
last_polled_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
last_poll_status: Mapped[str | None] = mapped_column(String(32), nullable=True)
last_poll_error: Mapped[str | None] = mapped_column(Text, nullable=True)
+ backfill_status: Mapped[str] = mapped_column(String(32), nullable=False, default="pending")
+ backfill_started_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
+ backfill_completed_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
+ last_backfill_error: Mapped[str | None] = mapped_column(Text, nullable=True)
+
+
+class ServiceBackfillState(Base):
+ __tablename__ = "service_backfill_states"
+ __table_args__ = (UniqueConstraint("actor", "service", name="uq_service_backfill_state_actor_service"),)
+
+ id: Mapped[int] = mapped_column(Integer, primary_key=True)
+ actor: Mapped[str] = mapped_column(String(255), nullable=False)
+ service: Mapped[str] = mapped_column(String(32), nullable=False)
+ cursor_json: Mapped[dict | None] = mapped_column(JSON, nullable=True)
+ status: Mapped[str] = mapped_column(String(32), nullable=False, default="pending")
+ started_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
+ completed_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
+ last_error: Mapped[str | None] = mapped_column(Text, nullable=True)
+ updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)