Переглянути джерело

Merge branch 'dynamic-spider-chart' of fyindr/siimee into dev

tags/0.0.3^2
maeda 3 роки тому
джерело
коміт
d405bf48e1

+ 4
- 4
backend/db/data-generator/mock.js Переглянути файл

443
         },
443
         },
444
         {
444
         {
445
             response_key_id: 3,
445
             response_key_id: 3,
446
-            response_key_category: 'collaborative_vs_independent',
446
+            response_key_category: 'dynamic_vs_ordered',
447
             response_key_prompt:
447
             response_key_prompt:
448
-                'Do you structure and encourage your team to be a Collaborative or Independent environment?',
448
+                'Do you structure and encourage your team to be a Collaborative or Independent environment? (NEEDS UPDATED COPY)',
449
             response_key_description: 'first round draft scoring question',
449
             response_key_description: 'first round draft scoring question',
450
         },
450
         },
451
         {
451
         {
452
             response_key_id: 4,
452
             response_key_id: 4,
453
-            response_key_category: 'innovative_vs_conventional',
453
+            response_key_category: 'precise_vs_resourceful',
454
             response_key_prompt:
454
             response_key_prompt:
455
-                'Do you find higher success in employees on your team that are Innovative or Conventional?',
455
+                'Do you find higher success in employees on your team that are Innovative or Conventional? (NEEDS UPDATED COPY)',
456
             response_key_description: 'first round draft scoring question',
456
             response_key_description: 'first round draft scoring question',
457
         },
457
         },
458
         {
458
         {

+ 1
- 1
backend/db/seeds/04-responses.js Переглянути файл

28
     for (let i = 1; i <= len; i += 1) {
28
     for (let i = 1; i <= len; i += 1) {
29
         responsesToPush.push(responses.shift())
29
         responsesToPush.push(responses.shift())
30
         if (i % batchSize === 0 || i > responses.length) {
30
         if (i % batchSize === 0 || i > responses.length) {
31
-            // await knex('responses').insert(responsesToPush)
31
+            await knex('responses').insert(responsesToPush)
32
             responsesToPush = []
32
             responsesToPush = []
33
         }
33
         }
34
     }
34
     }

+ 1
- 2
backend/lib/services/profile/index.js Переглянути файл

62
             .withGraphFetched('tags')
62
             .withGraphFetched('tags')
63
             .withGraphFetched('responses')
63
             .withGraphFetched('responses')
64
             .withGraphFetched('user')
64
             .withGraphFetched('user')
65
-
66
         tagger.setProfileTags(matchingProfile, matchingProfile, this.tagLookup)
65
         tagger.setProfileTags(matchingProfile, matchingProfile, this.tagLookup)
67
-        const complete = new profiler.CompleteProfile(matchingProfile)
66
+        const complete = new profiler.CompleteProfile(matchingProfile, true)
68
         return complete
67
         return complete
69
     }
68
     }
70
 
69
 

+ 1
- 1
backend/lib/services/profile/profiler.js Переглянути файл

7
  * !: This needs to match the responseSchema in profiles.js
7
  * !: This needs to match the responseSchema in profiles.js
8
  */
8
  */
9
 class CompleteProfile {
9
 class CompleteProfile {
10
-    constructor(profile, type, includeResponses = false) {
10
+    constructor(profile, includeResponses = false, type) {
11
         this.user_id = profile.user_id // int user_id
11
         this.user_id = profile.user_id // int user_id
12
         this.profile_id = profile.profile_id // int profile_id
12
         this.profile_id = profile.profile_id // int profile_id
13
         this.user_name = profile.user.user_name // string user_name
13
         this.user_name = profile.user.user_name // string user_name

+ 1
- 0
frontend/src/components/ProfileCard.vue Переглянути файл

29
             SummaryBar(
29
             SummaryBar(
30
                 :aspects='aspects'
30
                 :aspects='aspects'
31
                 :is-tab='true'
31
                 :is-tab='true'
32
+                :name='card.name'
32
                 :tab-content='card.summary'
33
                 :tab-content='card.summary'
33
                 @tab-change='onTab'
34
                 @tab-change='onTab'
34
             )
35
             )

+ 19
- 6
frontend/src/components/SummaryBar.vue Переглянути файл

30
                     p {{ tabContent[item].tab }}
30
                     p {{ tabContent[item].tab }}
31
                     SpiderChart(
31
                     SpiderChart(
32
                         :labels='aspects.map(label => label.name)'
32
                         :labels='aspects.map(label => label.name)'
33
-                        :profile-data='profileScore'
33
+                        :profile-data='aspects.map(data => data.percentage)'
34
                         :target-data='targetScore'
34
                         :target-data='targetScore'
35
-                        profile-name='lucy'
35
+                        :profile-name='name'
36
                         v-if='isTab'
36
                         v-if='isTab'
37
                     )
37
                     )
38
 
38
 
62
 
62
 
63
 <script>
63
 <script>
64
 import SpiderChart from './SpiderChart.vue'
64
 import SpiderChart from './SpiderChart.vue'
65
+import { currentProfile } from '../services'
65
 
66
 
66
 export default {
67
 export default {
67
     components: { SpiderChart },
68
     components: { SpiderChart },
74
             required: true,
75
             required: true,
75
             type: Object,
76
             type: Object,
76
         },
77
         },
78
+        name:{
79
+            required:true,
80
+            type: String
81
+        },
77
         isTab: {
82
         isTab: {
78
             required: false,
83
             required: false,
79
             type: Boolean,
84
             type: Boolean,
86
         },
91
         },
87
     },
92
     },
88
     emits: ['tab-change'],
93
     emits: ['tab-change'],
89
-    data: () => ({
90
-        profileScore: [5.7, 5.2, 4.8, 5.2, 4.9, 4.9],
91
-        targetScore: [5.3, 4.8, 5.7, 4.8, 5.6, 4.8],
92
-    }),
94
+    computed: {
95
+        targetScore(){
96
+            try{
97
+                let aspectResponses = currentProfile._profile.responses.filter(r => [1,2,3,4,5,6].indexOf(r.response_key_id) !== -1)
98
+                return aspectResponses.map(r => Number(r.val)) 
99
+            }
100
+            catch(e){
101
+                console.warn('error: No aspect responses for current profile.')
102
+                return [1,1,1,1,1,1]
103
+            }
104
+        }
105
+    },
93
     methods: {
106
     methods: {
94
         onTabChanged(tabs) {
107
         onTabChanged(tabs) {
95
             this.$emit('tab-change', tabs)
108
             this.$emit('tab-change', tabs)

+ 20
- 1
frontend/src/entities/card/card.js Переглянути файл

40
 }
40
 }
41
 
41
 
42
 class Aspect {
42
 class Aspect {
43
-    constructor({ name, labels, percentage = 50 }) {
43
+    constructor({ name, labels, percentage = 1 }) {
44
         this.name = name
44
         this.name = name
45
         this.labels = labels
45
         this.labels = labels
46
         this.percentage = percentage
46
         this.percentage = percentage
73
     }),
73
     }),
74
 ]
74
 ]
75
 
75
 
76
+const responseKeyIdToAspectName = {
77
+    1: 'vision',
78
+    2: 'creativity',
79
+    3: 'dynamism',
80
+    4: 'precision',
81
+    5: 'focus',
82
+    6: 'attention',
83
+}
84
+
76
 /**
85
 /**
77
  * Class representing a profile card
86
  * Class representing a profile card
78
  * NOT to be confused with a profile
87
  * NOT to be confused with a profile
123
     c.ethinicity = profile?.profile_prefs?.ethnicity?.val
132
     c.ethinicity = profile?.profile_prefs?.ethnicity?.val
124
     c.locale = `${profile.city}, ${profile.state}`
133
     c.locale = `${profile.city}, ${profile.state}`
125
     c.email = profile.user_email
134
     c.email = profile.user_email
135
+
136
+
137
+    let aspectResponses = profile?.responses.filter(r => [1,2,3,4,5,6].indexOf(r.response_key_id) !== -1)
138
+    if(aspectResponses.length){ // if user has responses for aspects we overwrite default percentages
139
+        c.aspects.map(a => {
140
+            a.percentage = Number(aspectResponses.find(r => responseKeyIdToAspectName[r.response_key_id] == a.name).val )
141
+            return a 
142
+        })
143
+    }
144
+
126
     // TODO: delete me later
145
     // TODO: delete me later
127
     if (profile.profile_description) {
146
     if (profile.profile_description) {
128
         c.summary.updateTab('about', profile.profile_description)
147
         c.summary.updateTab('about', profile.profile_description)

Завантаження…
Відмінити
Зберегти