Let me provide some context for this following PR.
I analyzed my current endpoints, and I found I have 11 working at the time.
So far, I made a plan to reduce that to 6, which I think is more acceptable and they are also designed so that they are not called that often (opposite to the first version where I call requests on every change)
I wanted to submit first the biggest change, which is about bringing together:
getNearbyRestaurants -was called in routes/adventure
isRated - was called in routes/review
activeFeedback - was called in routes/review
So I basically saw that I was calling the last two endpoints everytime I changed my screen from viewing the restaurants, so I could determine if an experience was rated by user x and what was the active feedback that this experience wanted. By changing my viewing restaurants, I mean using this menu
So, I figured that if I already had a restaurants array, containing objects with most information of my restaurants, I could calculate within this call the active feedback and also pass this field where I said if the active user has reviewed that experience.
ACTIONS:
1) I wanted to clean the /routes/adventure.js file, and for that I sent the queries to its corresponding folder, as well as sending my long rankAndFilter function and getMean to another location, /functions/adventure.js
2) I also changed the format, so now it is a bit more ordered according to functions:
first in the restaurants endpoint, you may find the formatter to match restaurants and google maps values
Then both requests of restaurants, from google and my db
I added this determineDistance function instead of doing it directly inside the endpoint
QUESTIONS:
I am not so sure if the structure is understandable. I went was thinking of moving all functions to the functions folder, but I am not so sure if that is convenient considering that it kind of adds this referencing a lot to external files. I guess my question is if you would recommend it or what would be the best practice.
RESULTS:
So far what I changed is working as expected. I have this small mismatch because before, I would use an endpoint to find the information of the active feedback (that one also calculated by another endpoint). Now, I have the activeFeedback, but only the keys within my UI hook.
The next step is to add this endpoint where I will retrieve all feedback information and call it to the UI, so I just do something like a filter and then I have all the information. In other words, my endpoint will be called only once to store that data, and I will deal with finding the activeInformation in the UI.
Good morning everyone!
Let me provide some context for this following PR.
I analyzed my current endpoints, and I found I have 11 working at the time. So far, I made a plan to reduce that to 6, which I think is more acceptable and they are also designed so that they are not called that often (opposite to the first version where I call requests on every change)
I wanted to submit first the biggest change, which is about bringing together:
So I basically saw that I was calling the last two endpoints everytime I changed my screen from viewing the restaurants, so I could determine if an experience was rated by user x and what was the active feedback that this experience wanted. By changing my viewing restaurants, I mean using this menu
So, I figured that if I already had a restaurants array, containing objects with most information of my restaurants, I could calculate within this call the active feedback and also pass this field where I said if the active user has reviewed that experience.
ACTIONS:
1) I wanted to clean the /routes/adventure.js file, and for that I sent the queries to its corresponding folder, as well as sending my long rankAndFilter function and getMean to another location, /functions/adventure.js 2) I also changed the format, so now it is a bit more ordered according to functions:
QUESTIONS:
I am not so sure if the structure is understandable. I went was thinking of moving all functions to the functions folder, but I am not so sure if that is convenient considering that it kind of adds this referencing a lot to external files. I guess my question is if you would recommend it or what would be the best practice.
RESULTS:
So far what I changed is working as expected. I have this small mismatch because before, I would use an endpoint to find the information of the active feedback (that one also calculated by another endpoint). Now, I have the activeFeedback, but only the keys within my UI hook.
The next step is to add this endpoint where I will retrieve all feedback information and call it to the UI, so I just do something like a filter and then I have all the information. In other words, my endpoint will be called only once to store that data, and I will deal with finding the activeInformation in the UI.
Let me know if I was not cleared on something!