Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exam solved #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Exam solved #7

wants to merge 1 commit into from

Conversation

ibgomezo
Copy link

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.

  1. Get all notes of the evaluations grouped by student, that failed the exams. In order to group the elements, it uses the keys of an Object.
  2. For every student, get the state and it is used like key of an object, whose value is a counter of differents students.
  3. Send object before created

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant