Преглед изворни кода

:construction: Small optimization in surveycompleteview logic

tags/0.0.4
tomit4 пре 2 година
родитељ
комит
09bc193f3e
2 измењених фајлова са 6 додато и 9 уклоњено
  1. 1
    1
      frontend/src/views/OnboardingView.vue
  2. 5
    8
      frontend/src/views/SurveyCompleteView.vue

+ 1
- 1
frontend/src/views/OnboardingView.vue Прегледај датотеку

@@ -55,6 +55,7 @@ export default {
55 55
         invalidResponse: false,
56 56
     }),
57 57
     async created() {
58
+        // TODO: Troubleshoot bug where memberships are not returned from backend with 500 err
58 59
         // TODO: Troubleshoot bug where not all responses are returned at SurveyCompleteView
59 60
         console.log('currentProfile :=>', currentProfile)
60 61
         this.survey = await surveyFactory.createSurvey()
@@ -116,7 +117,6 @@ export default {
116 117
             })
117 118
         },
118 119
         async updateAnswers(payload) {
119
-            console.log('this.survey.steps :=>', this.survey.steps)
120 120
             if (payload) {
121 121
                 const k = payload.question.survey_stage
122 122
                 this.answered[k] = payload.input

+ 5
- 8
frontend/src/views/SurveyCompleteView.vue Прегледај датотеку

@@ -35,8 +35,7 @@ export default {
35 35
     created() {
36 36
         // TODO: Troubleshoot bug where not all responses are returned
37 37
         console.log('currentProfile :=>', currentProfile)
38
-        this.aspectQuestions = this.parseSurvey(this.surveySteps, false)
39
-        this.surveyStages = this.parseSurvey(this.surveySteps, true)
38
+        this.parseSurvey(this.surveySteps)
40 39
         this.aspectResponses = this.grabAspectResponses(
41 40
             currentProfile._profile.responses,
42 41
             this.aspectQuestions,
@@ -48,19 +47,17 @@ export default {
48 47
         )
49 48
     },
50 49
     methods: {
51
-        parseSurvey(surveySteps, isStage) {
52
-            const parsedAspects = {}
53
-            const parsedStages = {}
50
+        parseSurvey(surveySteps) {
54 51
             surveySteps.forEach(step => {
55 52
                 const isAspect = step.category === 'aspect'
56 53
                 if (isAspect) {
57
-                    parsedAspects[`${step.response_key_id}`] =
54
+                    this.aspectQuestions[`${step.response_key_id}`] =
58 55
                         step.response_key_prompt
59 56
                 } else {
60
-                    parsedStages[`${step.response_key_id}`] = step.survey_stage
57
+                    this.surveyStages[`${step.response_key_id}`] =
58
+                        step.survey_stage
61 59
                 }
62 60
             })
63
-            return isStage ? parsedStages : parsedAspects
64 61
         },
65 62
         grabResponsesFromProfile(aspectQuestions) {
66 63
             const aspectQuestionsKeys = Object.keys(aspectQuestions).map(Number)

Loading…
Откажи
Сачувај