Skip to content

Commit 98d2909

Browse files
committed
chore!: remove unit changes endpoint/table
Release-As: 1.12.0
1 parent 086a617 commit 98d2909

File tree

3 files changed

+42
-43
lines changed

3 files changed

+42
-43
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""remove unitchanges
2+
3+
Revision ID: 2c332002ee3f
4+
Revises: 3b1a337a1fe5
5+
Create Date: 2026-03-02 17:17:30.233013
6+
7+
"""
8+
9+
from typing import Sequence, Union
10+
11+
import sqlalchemy as sa
12+
from sqlalchemy.dialects import sqlite
13+
14+
from alembic import op
15+
16+
# revision identifiers, used by Alembic.
17+
revision: str = "2c332002ee3f"
18+
down_revision: Union[str, Sequence[str], None] = "3b1a337a1fe5"
19+
branch_labels: Union[str, Sequence[str], None] = None
20+
depends_on: Union[str, Sequence[str], None] = None
21+
22+
23+
def upgrade() -> None:
24+
"""Upgrade schema."""
25+
# ### commands auto generated by Alembic - please adjust! ###
26+
op.drop_table("unitchanges")
27+
op.execute("VACUUM")
28+
# ### end Alembic commands ###
29+
30+
31+
def downgrade() -> None:
32+
"""Downgrade schema."""
33+
# ### commands auto generated by Alembic - please adjust! ###
34+
op.create_table(
35+
"unitchanges",
36+
sa.Column("id", sa.INTEGER(), nullable=False),
37+
sa.Column("unit_id", sa.INTEGER(), nullable=False),
38+
sa.Column("changes", sqlite.JSON(), nullable=True),
39+
sa.Column("scraped_at", sa.INTEGER(), nullable=False),
40+
sa.PrimaryKeyConstraint("id"),
41+
)
42+
# ### end Alembic commands ###

api/models.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -517,17 +517,6 @@ def search_query(self) -> str:
517517
"""
518518

519519

520-
# TODO: REMOVE
521-
class UnitChanges(BaseModel, table=True):
522-
"""We keep track of changes that get applied to learning units"""
523-
524-
id: int | None = Field(default=None, primary_key=True)
525-
unit_id: int
526-
changes: dict[str, object] = Field(sa_column=Column(JSON()))
527-
scraped_at: int
528-
"""The scraped_at before the changes were applied"""
529-
530-
531520
# TODO: move to metadata db
532521
class FinishedScrapingSemester(BaseModel, table=True):
533522
"""Keeps track of which semesters have been fully scraped already."""

api/routers/v1/units.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
LearningUnit,
1111
Level,
1212
Periodicity,
13-
UnitChanges,
1413
UnitExaminerLink,
1514
UnitLecturerLink,
1615
)
@@ -67,37 +66,6 @@ async def get_unit_lecturers(
6766
return results
6867

6968

70-
@router.get(
71-
"/{unit_id}/changes",
72-
response_model=Sequence[UnitChanges],
73-
description="WILL BE REMOVED BEGINNING OF MARCH 2026. It's too broken.\n"
74-
+ "Get a list of changes that the course details have undergone. "
75-
+ "Changes are a JSON object that describe what the values were before they "
76-
+ "got updated to either the next change or whatever the model currently has.",
77-
deprecated=True,
78-
)
79-
async def get_unit_changes(
80-
unit_id: int,
81-
session: Annotated[AsyncSession, Depends(aget_session)],
82-
limit: Annotated[int, Query(gt=0, le=1000)] = 100,
83-
offset: Annotated[int, Query(ge=0)] = 0,
84-
) -> Sequence[UnitChanges]:
85-
with tracer.start_as_current_span("get_unit_changes") as span:
86-
span.set_attribute("unit_id", unit_id)
87-
span.set_attribute("limit", limit)
88-
span.set_attribute("offset", offset)
89-
query = (
90-
select(UnitChanges)
91-
.where(UnitChanges.unit_id == unit_id)
92-
.order_by(col(UnitChanges.scraped_at).desc())
93-
.offset(offset)
94-
.limit(limit)
95-
)
96-
results = (await session.exec(query)).all()
97-
span.set_attribute("result_count", len(results))
98-
return results
99-
100-
10169
@router.get("/{unit_id}/examiners", response_model=Sequence[int])
10270
async def get_unit_examiners(
10371
unit_id: int,

0 commit comments

Comments
 (0)