ufosc / SwampScheduler

The future of scheduling is here.
https://osc.rconde.xyz
GNU Affero General Public License v3.0
22 stars 43 forks source link

Cache fetched courses #51

Open hieunguyent12 opened 11 months ago

hieunguyent12 commented 11 months ago

In reference to Robert's comment https://github.com/ufosc/SwampScheduler/pull/26#discussion_r1320936890.

Expected behavior: When the user searches "MAC", all math courses are fetched like MAC2312, MAC2313, MAC1105, etc... What we want to do is cache all of these courses (I believe this is already the default behavior for React Query), so when the user queries a specific math course like MAC2312, we will fetch from the cache to get information for that specific course instead of refetching the API.

We can also fetch that course in the background and then update the cache with the latest information.

elicampos commented 6 months ago

Can I claim this issue?

hieunguyent12 commented 6 months ago

Yes, go ahead! I never really made any progress on this.

elicampos commented 6 months ago

Hello! I managed to get it working under a new branch but for some reason it's not giving me permission to push. I tried doing it on Linux and Windows. I implemented a system in which it caches the searches and the individuals courses. So if you search something that was previously searched, it will still pull from the cache(Basic React Query which you guys already had), however during this process it also caches each course found. So now for each course search, it sees if the result was a search or course and if neither it calls the API again. The only drawback to this is the fact that very large searches like "EEL" for example, take about 30% longer, as it's caching all the courses but again now every course with EEL pops up almost instantly.