You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
New Flow
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
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.
The text was updated successfully, but these errors were encountered:
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
New Flow
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 -
website/src/constants.ts
Line 79 in ae9fbb6
Your Goal
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.fetchGpa
function insrc/data/beans/Course.ts
(this function is called insrc/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.The text was updated successfully, but these errors were encountered: