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: Ibrian Gomez Ortiz
Explain your solution
Excercise 1 - Add filter by technologyId for GET /courses endpoint
It added to filterFields, the value "technologyId" (controllers/courses.js)
Excercise 2 - create a GET /admin/billing/getInvoices
The "getChargeableStudents" method was refactorized due this send a response. Part of the code of "getChargeableStudents" was copied into "getChargeables".
"callAFIP" asynchronous method was created and this return a promise resolve only if the status is success.
In order to control every call to AFIP that returns with error has a new chance, a queue was used. If AFIP response with an error, the element will be added to queue again.
Excercise 3 - Add Middleware for caching GET requests
The "cacheMiddleware" was implemented and it was necesary to modify "responseHelpers".
"cacheMiddleware" is called first and then "responseHelpers". Due this "responseHelpers" manage the load of caché and "cacheMiddleware" query and delete elements of caché.
The methods POST and PUT remove elements of the caché, but every method use a different condition. Due this and to modularize the code, the methods "postCondition" and "putCondition" were implemented.
If POST is called, it should remove the "req.originalUrl" from caché.
If PUT is called, it should remove "req.originalUrl" and the entry that match with the parent url (if url is "/courses/1235" the parent is "/courses").
The routes that don't need be cached, are stored into an array.
Excercise 4 - create GET /stats/failuresByStates
Due to an inneficient modeling of data, it was neccesary to resolve the task step by step.
Share your ideas about the application
Would you change anything about how the app was designed?
Maybe I should change the data modeling to make the query more efficient.
What else would you add to it?