Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Name: Pablo Velazquez
Explain your solution
Tell us how you solved each of the excercises.
Excercise 1 - Add filter by technologyId for GET /courses endpoint
First i made the initial tests structure and then coded some test for filtering courses by technologyId.
Next Just added the attribute technologyId to filterFields array in courses controller and the tests ran satisfactorily
Problems:
Excercise 2 - create a GET /admin/billing/getInvoices
Firts i made some adjust to initial data loaded on test-db and coded some test looking for expected results.
I decided to compare the test request against the already working original request /api/admin/billing/getChargeableStudents
Then i started working on endpoint /admin/billing/getInvoices in controllers/billing.js
I had some doubts about refactoring the function getChargeableStudents for be available to use without request it via API, but finally decided to not refactoring and coded another promise based function using request module of nodeJS. Request module is required on app.js an then passed by parameter to the controller.
Problems:
Excercise 3 - Add Middleware for caching GET requests
In this issue i just started coding the middleware without test coz no ones came to my mind. i had some doubts about overriding the helper function res.response200, i feel like its very dangerous.
The solution consist on a <Key,Value> array with GET request as keys and response data as values. On each GET request we find first on cache and returns the value if is found, if not then pass to next() and the overrided res.response200 will cache the response for the next request.
Finally when a PUT o POST request is received the middleware deletes the keys from the cache asociated with that invidual resource and with all the list/find endpoints of that resource type.
Problems:
Excercise 4 - create GET /stats/failuresByStates
Started building a simple test on the endpoint /stats/failuresByStates
Added the stats controller with a function failuresByStates. Solving this one, i fell in love with the reduce function of arrays.
Problems:
Share your ideas about the application
Would you change anything about how the app was designed?
Some doubts about Data Modeling: Why no relations between schemas?
What else would you add to it?
Its okey for me. The excercises are fun and challenging