BE ‐ Polls table: Research how polls are created - JU-DEV-Bootcamps/ERAS GitHub Wiki
The polls are created following the steps described below:
- Login into the SES application
- Go to List Evaluation Processes and Add a new Evaluation
- when it's created then click on "Go to import" button
- Import Answers
- Save
While these steps are executed several requests against cosmic latte are trigger most of them are similar or contain small differences like adding body to the request or serialize the response on different models which is a really complex management for something that can be solve by third party like refit (Please take a look at: Refit Use on .Net)
First let me describe the requests when and where are executed:
-
Login into the SES application
-
Go to List Evaluation Processes and Add a new Evaluation
-
when its created then click on "Go to import" button
Class: CosmicLatteAPIService Method: GetPollsNameList URI: https://staging.cosmic-latte.com/api/1.0/evaluationSets?$top=100
-
Import Answers
Class: CosmicLatteAPIService Method: GetAllPollsPreview
Class: CosmicLatteAPIService Method: GetEvaluationSetIdAsync URI: https://staging.cosmic-latte.com/api/1.0/evaluationSets?$top=100Class: CosmicLatteAPIService Method: GetComponentsAndVariablesAsync Uri: https://staging.cosmic-latte.com/api/1.0/evaluations/exec/evaluationDetails foreach (var responseToPollInstance in apiResponse.data) { Class: CosmicLatteAPIService Method: PopulateListOfComponentsByIdPollInstanceAsync Uri: https://staging.cosmic-latte.com/api/1.0/evaluations/exec/evaluationDetails } -
Save
as you can see some requests are executed twice or more on different stages of the process getting the same data over and over some of them are even executed on cycle which increase processing for something we already know so refactoring this code need to develop two approaches:
- Replace CosmicLatteAPIService URI Requests for a Refit Interface that can be added through dependency Injection
- Refactor the code so those duplicated requested responses are reduce and cache them while the endpoint is executed on step 4