Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): convert last few routes to use token instead of old models #1195

Merged
merged 17 commits into from
Sep 12, 2024

Conversation

ollibowers
Copy link
Collaborator

@ollibowers ollibowers commented Sep 8, 2024

tldr

  • no more routes require user data in body
  • no more 1000000 user representations, shrunk down to 2-3
    • Storage: the current in-use database representation (to be soon removed since we have the new database models)
    • User: the algorithm representation
  • no more circular dependencies

major

  • converted last routes away from user payloads
    • /courses/getAllUnlocked
    • /courses/unselectCourse/{course}
    • /courses/coursesUnlockedWhenTaken/{course}
    • /ctf/validateCtf (indirectly)
    • /planner/autoplanning
  • converted frontend api requests and queries accordingly
  • updated all tests accordingly
    • added new example users to support this (derived from 'exampleUser.json')
  • created new functions to support this culling
    • created user_storage_to_algo_user(Storage) -> User as the fundamental bridge between the main two user representations
    • derived get_all_course_states_for_user(User) -> CourseStates from /courses/getAllUnlocked body
    • created parse_mark_to_int(Mark) -> Optional[int]
    • created user_storage_to_raw_plan(Storage) -> RawUserPlan to attach UOC and Marks to user planner (for easier term validation)
  • removed some no-longer used models and bad functions
    • removed fix_user_data (previously used to add UOC to old planner dicts)
    • removed convert_to_planner_data and ValidPlannerData (previously used for validate_terms)
    • removed UserData (previously used by payload routes)
    • removed ValidCourseState and ValidCoursesState
    • removed PlannerData (previously used by autoplanning)
    • removed prepareUserPayload frontend helper
  • convert validate_terms function to use new RawUserPlan type
    • this is a shape that is derived from combing user planner and course marks
  • removed markMap from backend, and unified all letter grade conversions

minor

  • add new type annotation for User::load_json
  • removed env file reliance in 'oidc/constants.py'
  • changed no-unused-vars and import order eslint rules to be warning, so compilation is still possible
  • changed eslint script to treat warnings as a fail

@ollibowers ollibowers changed the base branch from dev to 331-staging September 8, 2024 15:37
@ollibowers ollibowers linked an issue Sep 8, 2024 that may be closed by this pull request
@ollibowers ollibowers marked this pull request as ready for review September 8, 2024 17:07
@ollibowers ollibowers requested a review from a team as a code owner September 8, 2024 17:07
Copy link
Contributor

@martanman martanman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ollibowers ollibowers merged commit 72801cf into 331-staging Sep 12, 2024
8 checks passed
@ollibowers ollibowers deleted the refactor/api/tokenify-payload-routes branch September 12, 2024 14:59
justjo3l pushed a commit that referenced this pull request Sep 20, 2024
…#1195)

* fix: change eslint rules so frontend can compile with unused variables

* wip: created mirrored prepareUserPayload backend helper and converted

* fix: tokenified the  route

* fix: coursesUnlockedWhenTaken and getAllUnlocked tests now use tokens

* remove prepareUserPayload from frontend

* feat: created  function, and finally removed old UserData model

* fix: unselect tests now use token

* added note into unselectCourse route

* fix: aligned mark mappings to the WAM spec

* wip: move out convert_to_planner_data

* feat: removed  model and reworked  route

* fix: convert ctf to fully use user Storage

* feat: convert /validateTermPlanner to no longer use old models

* fix: update frontend mark parsing to match backend

* fix: re-enable circular imports pylint and remove type keyword

* fix: remove potentially bad load_dotenv

* fix: remove unused props for CourseDescriptionPanel and CourseMenu after tokenifying last routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tokenify the last few payload routes
2 participants