Skip to content
Merged
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
8 changes: 8 additions & 0 deletions validator/api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
from glob import glob
import sentry_sdk
from flask import Flask, Response, request, make_response
from http import HTTPStatus
from flask_cors import CORS
Expand All @@ -11,6 +12,13 @@
DegreeNotFoundException,
)

sentry_sdk.init(
dsn="https://3ee7dc417c569e7069bf9d6f18a5c14a@o4504918397353984.ingest.us.sentry.io/4509591448846336",
# Add data like request headers and IP for users,
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
)


class APIError(Exception):
def __init__(self, message: str, http_response_code: int = 400) -> None:
Expand Down
31 changes: 13 additions & 18 deletions validator/degree_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,27 +191,22 @@ def load_requirements(
year = max([degree_requirements_input.year, 2022])
if input_req not in degree_plans[str(year)]:
# Check if the years before this one have it
y = year
while str(y := y - 1) in degree_plans:
y = year - 1
while y >= 2022:
if input_req in degree_plans[str(y)]:
year = y
break
if (
year != degree_requirements_input.year
): # The using_year has been replaced to a working year
break
# Check if the years after this one have it
y = year
while str(y := y + 1) in degree_plans:
if input_req in degree_plans[str(y)]:
year = y
break
if (
year != degree_requirements_input.year
): # The using_year has been replaced to a working year
break
print("Error: Could not find the degree")
raise DegreeNotFoundException
y = y - 1
else:
# Check if the years after this one have it
y = year
while str(y := y + 1) in degree_plans:
if input_req in degree_plans[str(y)]:
year = y
break
else:
print("Error: Could not find the degree")
raise DegreeNotFoundException
requirements_data = degree_plans[str(year)][input_req]["requirements"][
"major"
]
Expand Down
1 change: 1 addition & 0 deletions validator/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ rich==13.9.4
rpds-py==0.25.1
ruamel.yaml==0.18.12
ruamel.yaml.clib==0.2.12
sentry-sdk==2.32.0
six==1.17.0
soupsieve==2.7
tomli==2.2.1
Expand Down
Loading