Skip to content

Commit

Permalink
add transfer route to api
Browse files Browse the repository at this point in the history
  • Loading branch information
Highfire1 committed Jun 22, 2024
1 parent 9041d45 commit 8b1b4ae
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
25 changes: 22 additions & 3 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from sdk.schema.CourseSummary import CourseSummaryDB
from sdk.schema.ScheduleEntry import ScheduleEntryDB
from sdk.schema.Section import SectionDB, SectionAPI
from sdk.schema.Transfer import TransferDB
from sdk.schema.Transfer import TransferAPI, TransferDB

from sdk.schema.BaseModels import Course, Semester

Expand Down Expand Up @@ -303,7 +303,7 @@ async def semesterSectionsInfo(
section = results.first()

if section == None:
return 404
raise HTTPException(status_code=404, detail="Course not found.")

statement = select(ScheduleEntryDB).where(ScheduleEntryDB.year == year, ScheduleEntryDB.term == term, ScheduleEntryDB.crn == crn)
results = session.exec(statement)
Expand All @@ -316,7 +316,26 @@ async def semesterSectionsInfo(
out["schedule"].append(s.model_dump())

return out


@app.get(
"/transfers/{institution_code}",
summary="Transfer information.",
description="Get all available transfers to a given institution.",
response_model=list[TransferAPI]
)
async def semesterSectionsInfo(
*,
session: Session = Depends(get_session),
institution_code: str,
):
statement = select(TransferDB).where(TransferDB.destination == institution_code).order_by(col(TransferDB.credit).asc())
results = session.exec(statement)
transfers = results.all()

if transfers == None:
raise HTTPException(status_code=404, detail="Institution not found.")

return transfers

# my wares are too powerful for you, traveller
@app.get(
Expand Down
4 changes: 2 additions & 2 deletions sdk/schema/Transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class Transfer(SQLModel):
source_credits: Optional[float] = Field(description="Credits at the source institution.")
source_title : Optional[str] = Field(description="Course title at the source institution.")

destination: str = Field(description="Destination institution code e.g. ```SFU```.")
destination: str = Field(index=True, description="Destination institution code e.g. ```SFU```.")
destination_name: str = Field(description="Destination institution full name e.g. ```Simon Fraser University```.")

credit: str = Field(description="How many credits is the course worth at the source institution.")
credit: str = Field(index=True, description="How many credits is the course worth at the source institution.")
condition: Optional[str] = Field(description="Additional conditions that apply to the credit transfer.")

effective_start: str = Field(description="When this transfer agreement began.")
Expand Down

0 comments on commit 8b1b4ae

Please sign in to comment.