-
Notifications
You must be signed in to change notification settings - Fork 8
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
Switch to an external cloud function to store requirements JSON #889
Open
Destaq
wants to merge
6
commits into
main
Choose a base branch
from
simon/use-requirements-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
67446aa
checkpoint: working if previously used cp
Destaq 51fdc32
chore: run formatter
Destaq e7db33e
feat: full dynamic json req support
Destaq 62d73d2
chore: reformat
Destaq 722145e
chore: change url to (local) firebase cloud function
Destaq 46d0b70
fix: fetch requirements subgraph on onboarding
Destaq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[ | ||
[ | ||
"AG", | ||
"Agriculture and Life Sciences" | ||
], | ||
[ | ||
"AR", | ||
"Architecture, Art and Planning" | ||
], | ||
[ | ||
"AS", | ||
"Arts and Sciences" | ||
], | ||
[ | ||
"EN", | ||
"Engineering" | ||
], | ||
[ | ||
"HE", | ||
"Human Ecology" | ||
], | ||
[ | ||
"IL", | ||
"Industrial Labor Relations" | ||
], | ||
[ | ||
"BU", | ||
"SC Johnson College of Business" | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { DecoratedRequirementsJson } from './types'; | ||
|
||
// TODO: update to real firebase function URL | ||
const BASE_URL = 'http://127.0.0.1:5001/advanced-todos-73680/us-central1/api/requirements'; | ||
|
||
export default async function getDecoratedRequirementsJson( | ||
major?: readonly string[], | ||
minor?: readonly string[], | ||
college?: string, | ||
grad?: string | ||
): Promise<DecoratedRequirementsJson> { | ||
try { | ||
let formattedMajors = (major ?? []).join(','); | ||
if (formattedMajors.length === 0) { | ||
formattedMajors = 'skip-this'; | ||
} | ||
|
||
let formattedMinors = (minor ?? []).join(','); | ||
if (formattedMinors.length === 0) { | ||
formattedMinors = 'skip-this'; | ||
} | ||
|
||
let formattedGrad = grad; | ||
if (!grad) { | ||
formattedGrad = 'skip-this'; | ||
} | ||
|
||
const route = `${BASE_URL}?major=${formattedMajors}&minor=${formattedMinors}&college=${college}&grad=${formattedGrad}`; | ||
const response = await fetch(route); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error! status: ${response.status}`); | ||
} | ||
const data = (await response.json()) as DecoratedRequirementsJson; | ||
return data; | ||
} catch (e) { | ||
// FIXME: the alternative is to return a default json, but that | ||
// defeats the whole purpose. Maybe throw an error here? | ||
return {} as DecoratedRequirementsJson; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
[ | ||
"MPA", | ||
"Master of Public Administration (MPA) Program" | ||
] | ||
] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't super clear. Essentially what I mean here is that if you click to pick a new major (or college or minor or grad), we don't fetch from the cloud function to get the requirements for that major. Doing so would take say 0.5 seconds and so the warning would flash for 0.5 seconds, as the current requirement json has no information about whatever new choice you made and would hence think it is invalid.