CasualCodersProjects / dreambg-web

https://dreambg.cc
0 stars 0 forks source link

Optimize API calls #39

Closed chand1012 closed 1 year ago

chand1012 commented 1 year ago

Currently, just with Kyle and I testing the app, we had 27 thousand API calls in a matter of a few hours.

image

We should optimize this. Currently as it stand to simplify design, each ImageCard object calls the API individually. This was also so that the image card can be reused on the image page. One optimization I'm making as a part of #20 is only getting the download links when they press the download button.

We will take down a server if we keep doing this, should be fixed before we start marketing.

chand1012 commented 1 year ago

One possible solution is to use SQL views in order to create a single view that can get all of the information we need. That information includes

This would then be batched and called once per virtual page rather than once per image. This would significantly decrease the amount of API calls we make while testing and when in production.

chand1012 commented 1 year ago

The initial changes were done here: 6dafa0840f7f70be09354a5e902feb3476c64ede

Still need to finish the search function so that's not completely broken as well. Once that's done we can close this issue.

chand1012 commented 1 year ago

Finished, see 78911f6d0c3335ef63a2a71bb717a930b6863805