Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions alembic/versions/2c332002ee3f_remove_unitchanges.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""remove unitchanges

Revision ID: 2c332002ee3f
Revises: 3b1a337a1fe5
Create Date: 2026-03-02 17:17:30.233013

"""

from typing import Sequence, Union

import sqlalchemy as sa
from sqlalchemy.dialects import sqlite

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "2c332002ee3f"
down_revision: Union[str, Sequence[str], None] = "3b1a337a1fe5"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("unitchanges")
op.execute("VACUUM")
# ### end Alembic commands ###


def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"unitchanges",
sa.Column("id", sa.INTEGER(), nullable=False),
sa.Column("unit_id", sa.INTEGER(), nullable=False),
sa.Column("changes", sqlite.JSON(), nullable=True),
sa.Column("scraped_at", sa.INTEGER(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
# ### end Alembic commands ###
11 changes: 0 additions & 11 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,17 +517,6 @@ def search_query(self) -> str:
"""


# TODO: REMOVE
class UnitChanges(BaseModel, table=True):
"""We keep track of changes that get applied to learning units"""

id: int | None = Field(default=None, primary_key=True)
unit_id: int
changes: dict[str, object] = Field(sa_column=Column(JSON()))
scraped_at: int
"""The scraped_at before the changes were applied"""


# TODO: move to metadata db
class FinishedScrapingSemester(BaseModel, table=True):
"""Keeps track of which semesters have been fully scraped already."""
Expand Down
32 changes: 0 additions & 32 deletions api/routers/v1/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
LearningUnit,
Level,
Periodicity,
UnitChanges,
UnitExaminerLink,
UnitLecturerLink,
)
Expand Down Expand Up @@ -67,37 +66,6 @@ async def get_unit_lecturers(
return results


@router.get(
"/{unit_id}/changes",
response_model=Sequence[UnitChanges],
description="WILL BE REMOVED BEGINNING OF MARCH 2026. It's too broken.\n"
+ "Get a list of changes that the course details have undergone. "
+ "Changes are a JSON object that describe what the values were before they "
+ "got updated to either the next change or whatever the model currently has.",
deprecated=True,
)
async def get_unit_changes(
unit_id: int,
session: Annotated[AsyncSession, Depends(aget_session)],
limit: Annotated[int, Query(gt=0, le=1000)] = 100,
offset: Annotated[int, Query(ge=0)] = 0,
) -> Sequence[UnitChanges]:
with tracer.start_as_current_span("get_unit_changes") as span:
span.set_attribute("unit_id", unit_id)
span.set_attribute("limit", limit)
span.set_attribute("offset", offset)
query = (
select(UnitChanges)
.where(UnitChanges.unit_id == unit_id)
.order_by(col(UnitChanges.scraped_at).desc())
.offset(offset)
.limit(limit)
)
results = (await session.exec(query)).all()
span.set_attribute("result_count", len(results))
return results


@router.get("/{unit_id}/examiners", response_model=Sequence[int])
async def get_unit_examiners(
unit_id: int,
Expand Down