carlosvegap / capstone-kickoff

0 stars 0 forks source link

Attach feedbackInfo to restaurants #73

Open CarLosVegga opened 1 year ago

CarLosVegga commented 1 year ago

Is this feedback per restaurant? If so maybe we should attach it directly to each Restuarant object.

_Originally posted by @vqdo in https://github.com/carlosvegap/capstone-kickoff/pull/60#discussion_r937926049_

CarLosVegga commented 1 year ago

In this case I am storing the information of ALL preferences. (like Distance is not directly proportional, it can be from 0 to 15km, etc). So, it is information I use for rendering for example the slider to set if restaurants should go over or below a threshold.

So before the refactoring, the way this was working was that every time an Adventurer added/deleted a preference, it would make a call to one of my endpoints with the array of IDs and expect it to return all the information to that array (now I see it was a horrible implementation! haha)

To improve that and reduce the number of requests as well as unnecessary data traffic, I call all the feedback information at the beginning, and as changes start to happen, I simply use the keys to find the information of those arrays.

Still, I am now seeing that maybe from the db, I could retrieve the array of active IDs, on my server already deal with matching the information (so that I get all the information corresponding to every key), and I just play with sending that object to the active or inactive state within the UI. And when saving changes, just post the id key to the db. I think that could save performance since now instead of doing the pairing of the feedbackInfo to the active and inactive arrays, I have that information in the active and inactive arrays and I simply move it from one another according to user's interaction