BE ‐ Polls table: Research how polls are created - JU-DEV-Bootcamps/ERAS GitHub Wiki

The polls are created following the steps described below:

  1. Login into the SES application
  2. Go to List Evaluation Processes and Add a new Evaluation
  3. when it's created then click on "Go to import" button
  4. Import Answers
  5. 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:

  1. Login into the SES application

  2. Go to List Evaluation Processes and Add a new Evaluation

  3. 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

  4. Import Answers

    Class: CosmicLatteAPIService Method: GetAllPollsPreview

     Class: CosmicLatteAPIService
     Method: GetEvaluationSetIdAsync
     URI: https://staging.cosmic-latte.com/api/1.0/evaluationSets?$top=100
    

    Uri: https://staging.cosmic-latte.com/api/1.0/evaluations?$top=1000&$filter=contains(parent,'evaluationSets:zqkFLdudnLi8hRKqH')

     Class: 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
     }
    
  5. 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:

  1. Replace CosmicLatteAPIService URI Requests for a Refit Interface that can be added through dependency Injection
  2. Refactor the code so those duplicated requested responses are reduce and cache them while the endpoint is executed on step 4