magshimim-next / cv-next

A simple cv upload and peer review system
7 stars 2 forks source link

Trim down amount of CV-related API calls #191

Open YechiamW3 opened 3 weeks ago

YechiamW3 commented 3 weeks ago

We currently have, for each CV in the Feed page, 3 API calls. This means, we have 3*(amount of cvs in viewport) requests each time (let's say 6, as per the current CVS_PER_PAGE number). Meaning 18 calls. This is a huge network load, we have to take care of it before release, imo.

The API calls are the following:

  1. revalidatePreview: or, essentially, load the preview image
  2. getAuthorName: retrieve the CV's author name
  3. getBlurCv: load the blur-version of the cv

I think we should discuss how exactly to solve each call, in a way that either moves it into a different call that already happens, or at the very least unites multiple calls together.

For example, I don't think there's a reason why getAuthorName shouldn't already be in the CV's data, if we use it so much in the feed.

The blur and preview, we've talked about the option to generate those in a cron job (or similar server job).

Anyway, let's talk about this, because I think performance-wise (which is quite important; it affects the main page of the project), this should be somewhere in the top priority.

Aradon267 commented 3 weeks ago

The author's name as you said can be fixed with a simple innerjoin

We can have a small server that uploads it based on a cronjob, I think that @AdamLiberov had a PoC of getting updates using google API with python so we can integrate that in as the upload mechanism for supabase with python is also rather simple

nevogithub commented 3 weeks ago

TODO - write to @YechiamW3 and @AdamLiberov about current progress in this issue