feat: add cached homepage information and manual AI interpretations

This commit is contained in:
yuxuanhui
2026-09-12 01:55:24 +08:00
parent 394438e753
commit d9fbaa7cf7
19 changed files with 1674 additions and 18 deletions
@@ -0,0 +1,35 @@
"""Persist account-scoped homepage information, interpretations and comparable ranks."""
import sqlalchemy as sa
from alembic import op
revision = "0016"
down_revision = "0015"
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
"home_information",
sa.Column("user_id", sa.String(100), primary_key=True),
sa.Column("resource", sa.String(200), primary_key=True),
sa.Column("content", sa.JSON(), nullable=True),
sa.Column("version", sa.String(64), nullable=True),
sa.Column("fetched_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("error", sa.Text(), nullable=True),
sa.Column("analysis", sa.JSON(), nullable=True),
)
op.create_table(
"home_rank_history",
sa.Column("id", sa.String(36), primary_key=True),
sa.Column("user_id", sa.String(100), nullable=False),
sa.Column("scope", sa.String(200), nullable=False),
sa.Column("rank", sa.Integer(), nullable=False),
sa.Column("fetched_at", sa.DateTime(timezone=True), nullable=False),
)
op.create_index("ix_home_rank_history_user_id", "home_rank_history", ["user_id"])
def downgrade():
op.drop_table("home_rank_history")
op.drop_table("home_information")