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

[BoG S24] Improve getCourseDataFromCourseCritique Data Flow #301

Open
yatharth-b opened this issue Mar 5, 2024 · 0 comments · May be fixed by #314
Open

[BoG S24] Improve getCourseDataFromCourseCritique Data Flow #301

yatharth-b opened this issue Mar 5, 2024 · 0 comments · May be fixed by #314
Assignees
Labels
task Task issue for a current or past sprint

Comments

@yatharth-b
Copy link
Contributor

yatharth-b commented Mar 5, 2024

Problem Description

GTS needs data from course critique to operate. This data is fetched with the following flow (image below). The cloud function currently caches the API data in firestore. However, this data in firestore can be accessible from the client if we update the firestore rules. This access from client side is also safe, since the course data is not private and is being accessed by all users anyway. This presents a possible optimization which can help us reduce our firebase costs by reducing function invocations by a big margin.

Old Flow

image

New Flow

image

The functioning of the cloud function remains the exact same, but we're changing how data is fetched on the client now (adding a new step to first check firestore after checking local storage before fetching data from the cloud function).

Note : run the firebase-conf repo locally and change the base url in the website repo to use local firebase functions.
firebae-conf repo contains all the cloud functions - https://github.com/gt-scheduler/firebase-conf/tree/main

change url to localhost here -

const CLOUD_FUNCTION_BASE_URL = `https://us-east1-${FIREBASE_PROJECT_ID}.cloudfunctions.net`;

Your Goal

  • Branch from main
  • Refer to the development firebase project (ask EM for access) for more information on how course_critique_course_data_cache is structured. Also read https://github.com/gt-scheduler/firebase-conf/blob/main/functions/src/course_critique_cache.ts to figure out how to decode information stored in this collection as well as what the fields signify.
  • Edit the fetchGpa function in src/data/beans/Course.ts (this function is called in src/Components/Course/index.tsx to populate the UI) to now first check firestore for a valid cache entry (this code can be taken from the cloud function) after an invalid entry is found in localStorage and then proceed to make a cloud function call only when localStorage and firebase have an invalid entry. The code currently only checks localStorage.
  • Do thorough testing to make sure this entire flow works as expected.
@yatharth-b yatharth-b added the task Task issue for a current or past sprint label Mar 5, 2024
@iphonecats iphonecats linked a pull request Mar 26, 2024 that will close this issue
4 tasks
@iphonecats iphonecats linked a pull request Mar 26, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task Task issue for a current or past sprint
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants