Skip to content

feat: bundle Hoagie requirements data locally and serve at page load#512

Closed
angelina-ji wants to merge 1 commit intomasterfrom
feat/hoagie-requirements-data
Closed

feat: bundle Hoagie requirements data locally and serve at page load#512
angelina-ji wants to merge 1 commit intomasterfrom
feat/hoagie-requirements-data

Conversation

@angelina-ji
Copy link
Copy Markdown
Contributor

Bundle Hoagie requirements data locally and serve at page load

PROBLEM:
TigerPath fetches requirements from the old branch of Princeton-Departmental-Data over HTTP — that data is outdated and the network fetch causes the requirements sidebar to flash in after a delay.

CHANGES:
Copied HoagieClub/plan's MIT-licensed YAML data into tigerpath/requirements_data/ (majors, minors, certificates, degrees)
Replaced the remote HTTP fetch in verifier.py with local file reads
Pre-compute requirements in the Django index view and inject into the HTML so the sidebar renders instantly on page load
Frontend checks for preloaded data before falling back to the API fetch

TESTING:
Log in, select a major, reload — requirements sidebar should appear instantly
DevTools → Network → filter get_requirements → hard refresh — zero requests on initial load

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0924da8092

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +74 to +75
if (window.__TIGERPATH_PRELOADED_REQUIREMENTS__) {
handleRequirementData(window.__TIGERPATH_PRELOADED_REQUIREMENTS__);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Fetch requirements when preload payload is empty

This condition treats an empty preloaded payload as success, so the API fallback never runs. In this commit the server can serialize [] for cases like unsupported majors or preload exceptions, and because [] is truthy in JavaScript, users can end up stuck with an empty requirements pane instead of the normal /api/v1/get_requirements/ result (which includes unsupported-major messaging and degree progress).

Useful? React with 👍 / 👎.

@@ -111,6 +111,11 @@
</script>
{% endif %}

{% if preloaded_requirements_json %}
<script>
window.__TIGERPATH_PRELOADED_REQUIREMENTS__ = {{ preloaded_requirements_json|safe }};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid injecting raw JSON into inline script

Rendering preloaded_requirements_json with |safe inside a <script> block allows script-breakout sequences like </script> in data values to terminate the block and inject executable HTML/JS. Requirement data can include user-provided external credit names, so this introduces a stored XSS vector on page load unless the payload is emitted with safe escaping (for example via Django's JSON-script escaping helpers).

Useful? React with 👍 / 👎.

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.

1 participant