Przeglądaj źródła

:gear: redoing prettier config | running prettier | adding some sample wave-ui elements

tags/0.0.1
J 3 lat temu
rodzic
commit
7a2e9df128
38 zmienionych plików z 361 dodań i 235 usunięć
  1. 8
    6
      backend/.prettierrc
  2. 1
    1
      backend/lib/index.js
  3. 1
    1
      backend/lib/plugins/survey.js
  4. 19
    13
      backend/lib/routes/membership/join.js
  5. 8
    4
      backend/lib/routes/notification/index.js
  6. 11
    7
      backend/lib/routes/profile/get.js
  7. 12
    8
      backend/lib/routes/profile/match.js
  8. 11
    7
      backend/lib/routes/profile/respond.js
  9. 11
    7
      backend/lib/routes/profile/update.js
  10. 5
    3
      backend/lib/routes/survey/questions.js
  11. 6
    4
      backend/lib/routes/survey/responses.js
  12. 1
    1
      backend/lib/routes/user/create-profile.js
  13. 1
    1
      backend/lib/routes/user/list-profiles.js
  14. 3
    1
      backend/lib/routes/user/login.js
  15. 4
    4
      backend/lib/routes/user/signup.js
  16. 1
    0
      backend/lib/services/matchqueue.js
  17. 21
    12
      backend/lib/services/notification.js
  18. 27
    18
      backend/lib/services/profile/index.js
  19. 34
    10
      backend/lib/services/profile/profiler.js
  20. 7
    7
      backend/lib/services/profile/scorer.js
  21. 2
    2
      backend/lib/services/profile/tagger.js
  22. 3
    3
      backend/lib/services/profile/zipcoder.js
  23. 5
    2
      backend/lib/services/user.js
  24. 2
    2
      backend/server/index.js
  25. 0
    0
      frontend/.eslintrc
  26. 1
    1
      frontend/.prettierrc
  27. 40
    50
      frontend/src/App.vue
  28. 1
    0
      frontend/src/components/MainNav.vue
  29. 3
    4
      frontend/src/components/Messages.vue
  30. 1
    2
      frontend/src/components/ProfileCardList.vue
  31. 5
    5
      frontend/src/components/SideBar.vue
  32. 8
    7
      frontend/src/main.js
  33. 12
    5
      frontend/src/views/HomeView.vue
  34. 6
    6
      frontend/src/views/LoginView.vue
  35. 7
    4
      frontend/src/views/MatchesView.vue
  36. 3
    1
      frontend/src/views/ProfileView.vue
  37. 63
    26
      frontend/src/views/SurveyView.vue
  38. 7
    0
      frontend/vite.config.js

+ 8
- 6
backend/.prettierrc Wyświetl plik

1
-trailingComma: "all"
2
-tabWidth: 4
3
-semi: false
4
-singleQuote: true
5
-bracketSpacing: true
6
-arrowParens: "avoid"
1
+{
2
+    "trailingComma": "all",
3
+    "tabWidth": 4,
4
+    "semi": false,
5
+    "singleQuote": true,
6
+    "bracketSpacing": true,
7
+    "arrowParens": "avoid"
8
+}

+ 1
- 1
backend/lib/index.js Wyświetl plik

41
         await server.register(ProfilePlugin, {
41
         await server.register(ProfilePlugin, {
42
             routes: { prefix: '/profile' },
42
             routes: { prefix: '/profile' },
43
         })
43
         })
44
-        
44
+
45
         await server.register(NotificationPlugin, {
45
         await server.register(NotificationPlugin, {
46
             routes: { prefix: '/notification' },
46
             routes: { prefix: '/notification' },
47
         })
47
         })

+ 1
- 1
backend/lib/plugins/survey.js Wyświetl plik

24
 
24
 
25
         await server.route(ResponseQuestionsRoute)
25
         await server.route(ResponseQuestionsRoute)
26
     },
26
     },
27
-    models: { ReponseKeyModel }
27
+    models: { ReponseKeyModel },
28
 }
28
 }

+ 19
- 13
backend/lib/routes/membership/join.js Wyświetl plik

15
 
15
 
16
 const validators = {
16
 const validators = {
17
     params: params.profileId,
17
     params: params.profileId,
18
-    payload: groupingSchema.single.append({
19
-        target_id: Joi.number().required(),
20
-        role: Joi.string(),
21
-    }).label('grouping_membership_single')
18
+    payload: groupingSchema.single
19
+        .append({
20
+            target_id: Joi.number().required(),
21
+            role: Joi.string(),
22
+        })
23
+        .label('grouping_membership_single'),
22
 }
24
 }
23
 
25
 
24
 const responseSchemas = {
26
 const responseSchemas = {
25
     response: Joi.object({
27
     response: Joi.object({
26
         memberships: Joi.array().items(),
28
         memberships: Joi.array().items(),
27
-        hasMatch: Joi.boolean()
29
+        hasMatch: Joi.boolean(),
28
     }).label('grouping_membership_list'),
30
     }).label('grouping_membership_list'),
29
-    error: errorSchema.single
31
+    error: errorSchema.single,
30
 }
32
 }
31
 
33
 
32
 module.exports = {
34
 module.exports = {
99
         /** Validate based on validators object */
101
         /** Validate based on validators object */
100
         validate: {
102
         validate: {
101
             ...validators,
103
             ...validators,
102
-            failAction: 'log'
104
+            failAction: 'log',
103
         },
105
         },
104
 
106
 
105
         /** Validate the server response */
107
         /** Validate the server response */
106
         response: {
108
         response: {
107
             status: {
109
             status: {
108
-                200: apiSchema.single.append({
109
-                    data: responseSchemas.response,
110
-                }).label('join_grouping_res'),
111
-                409: apiSchema.single.append({
112
-                    data: responseSchemas.error,
113
-                }).label('error_single_res'),
110
+                200: apiSchema.single
111
+                    .append({
112
+                        data: responseSchemas.response,
113
+                    })
114
+                    .label('join_grouping_res'),
115
+                409: apiSchema.single
116
+                    .append({
117
+                        data: responseSchemas.error,
118
+                    })
119
+                    .label('error_single_res'),
114
             },
120
             },
115
         },
121
         },
116
     },
122
     },

+ 8
- 4
backend/lib/routes/notification/index.js Wyświetl plik

15
 }
15
 }
16
 
16
 
17
 const validators = {
17
 const validators = {
18
-    params: params.profileId
18
+    params: params.profileId,
19
 }
19
 }
20
 
20
 
21
 module.exports = {
21
 module.exports = {
31
             const input = new PassThrough({ objectMode: true })
31
             const input = new PassThrough({ objectMode: true })
32
             const eventType = 'stonk'
32
             const eventType = 'stonk'
33
 
33
 
34
-            const msg = { profile_id, name: 'BDGRS', price: (500 + Math.floor(Math.random() * 100)).toString(), order: null }
34
+            const msg = {
35
+                profile_id,
36
+                name: 'BDGRS',
37
+                price: (500 + Math.floor(Math.random() * 100)).toString(),
38
+                order: null,
39
+            }
35
 
40
 
36
             // Write to the input stream
41
             // Write to the input stream
37
             setInterval(() => {
42
             setInterval(() => {
48
         /** Validate based on validators object */
53
         /** Validate based on validators object */
49
         validate: {
54
         validate: {
50
             ...validators,
55
             ...validators,
51
-            failAction: 'log'
56
+            failAction: 'log',
52
         },
57
         },
53
-
54
     },
58
     },
55
 }
59
 }

+ 11
- 7
backend/lib/routes/profile/get.js Wyświetl plik

20
 }
20
 }
21
 
21
 
22
 const validators = {
22
 const validators = {
23
-    params: params.profileId
23
+    params: params.profileId,
24
 }
24
 }
25
 
25
 
26
 module.exports = {
26
 module.exports = {
65
         /** Validate the server response */
65
         /** Validate the server response */
66
         response: {
66
         response: {
67
             status: {
67
             status: {
68
-                200: apiSchema.single.append({
69
-                    data: responseSchemas.profile,
70
-                }).label('profile_single_res'),
71
-                409: apiSchema.single.append({
72
-                    data: responseSchemas.error,
73
-                }).label('error_single_res'),
68
+                200: apiSchema.single
69
+                    .append({
70
+                        data: responseSchemas.profile,
71
+                    })
72
+                    .label('profile_single_res'),
73
+                409: apiSchema.single
74
+                    .append({
75
+                        data: responseSchemas.error,
76
+                    })
77
+                    .label('error_single_res'),
74
             },
78
             },
75
         },
79
         },
76
     },
80
     },

+ 12
- 8
backend/lib/routes/profile/match.js Wyświetl plik

3
 const Joi = require('joi')
3
 const Joi = require('joi')
4
 const apiSchema = require('../../schemas/api')
4
 const apiSchema = require('../../schemas/api')
5
 const errorSchema = require('../../schemas/errors')
5
 const errorSchema = require('../../schemas/errors')
6
-const surveyResponseSchema = require('../../schemas/responses') 
6
+const surveyResponseSchema = require('../../schemas/responses')
7
 
7
 
8
 const pluginConfig = {
8
 const pluginConfig = {
9
     handlerType: 'match',
9
     handlerType: 'match',
17
 
17
 
18
 const responseSchemas = {
18
 const responseSchemas = {
19
     response: surveyResponseSchema.list,
19
     response: surveyResponseSchema.list,
20
-    error: errorSchema.single
20
+    error: errorSchema.single,
21
 }
21
 }
22
 
22
 
23
 module.exports = {
23
 module.exports = {
66
         /** Validate the server response */
66
         /** Validate the server response */
67
         response: {
67
         response: {
68
             status: {
68
             status: {
69
-                200: apiSchema.single.append({
70
-                    data: responseSchemas.response,
71
-                }).label('response_list_res'),
72
-                409: apiSchema.single.append({
73
-                    data: responseSchemas.error,
74
-                }).label('error_single_res')
69
+                200: apiSchema.single
70
+                    .append({
71
+                        data: responseSchemas.response,
72
+                    })
73
+                    .label('response_list_res'),
74
+                409: apiSchema.single
75
+                    .append({
76
+                        data: responseSchemas.error,
77
+                    })
78
+                    .label('error_single_res'),
75
             },
79
             },
76
         },
80
         },
77
     },
81
     },

+ 11
- 7
backend/lib/routes/profile/respond.js Wyświetl plik

16
 
16
 
17
 const responseSchemas = {
17
 const responseSchemas = {
18
     response: surveyResponseSchema.list,
18
     response: surveyResponseSchema.list,
19
-    error: errorSchema.single
19
+    error: errorSchema.single,
20
 }
20
 }
21
 
21
 
22
 const validators = {
22
 const validators = {
91
         /** Validate the server response */
91
         /** Validate the server response */
92
         response: {
92
         response: {
93
             status: {
93
             status: {
94
-                201: apiSchema.single.append({
95
-                    data: responseSchemas.response,
96
-                }).label('response_list_res'),
97
-                409: apiSchema.single.append({
98
-                    data: responseSchemas.error,
99
-                }).label('error_single_res')
94
+                201: apiSchema.single
95
+                    .append({
96
+                        data: responseSchemas.response,
97
+                    })
98
+                    .label('response_list_res'),
99
+                409: apiSchema.single
100
+                    .append({
101
+                        data: responseSchemas.error,
102
+                    })
103
+                    .label('error_single_res'),
100
             },
104
             },
101
         },
105
         },
102
     },
106
     },

+ 11
- 7
backend/lib/routes/profile/update.js Wyświetl plik

16
 
16
 
17
 const responseSchemas = {
17
 const responseSchemas = {
18
     response: surveyResponseSchema.list,
18
     response: surveyResponseSchema.list,
19
-    error: errorSchema.single
19
+    error: errorSchema.single,
20
 }
20
 }
21
 
21
 
22
 const validators = {
22
 const validators = {
86
         /** Validate the server response */
86
         /** Validate the server response */
87
         response: {
87
         response: {
88
             status: {
88
             status: {
89
-                200: apiSchema.single.append({
90
-                    data: responseSchemas.response,
91
-                }).label('response_list_res'),
92
-                409: apiSchema.single.append({
93
-                    data: responseSchemas.error,
94
-                }).label('error_single_res')
89
+                200: apiSchema.single
90
+                    .append({
91
+                        data: responseSchemas.response,
92
+                    })
93
+                    .label('response_list_res'),
94
+                409: apiSchema.single
95
+                    .append({
96
+                        data: responseSchemas.error,
97
+                    })
98
+                    .label('error_single_res'),
95
             },
99
             },
96
         },
100
         },
97
     },
101
     },

+ 5
- 3
backend/lib/routes/survey/questions.js Wyświetl plik

59
 
59
 
60
         /** Validate the server response */
60
         /** Validate the server response */
61
         response: {
61
         response: {
62
-            schema: apiSchema.single.append({
63
-                data: responseSchemas.response
64
-            }).label('question_list_res'),
62
+            schema: apiSchema.single
63
+                .append({
64
+                    data: responseSchemas.response,
65
+                })
66
+                .label('question_list_res'),
65
             failAction: 'log',
67
             failAction: 'log',
66
         },
68
         },
67
     },
69
     },

+ 6
- 4
backend/lib/routes/survey/responses.js Wyświetl plik

25
     // payload: true,
25
     // payload: true,
26
 }
26
 }
27
 const responseSchemas = {
27
 const responseSchemas = {
28
-    response: surveyResponseSchema.keys
28
+    response: surveyResponseSchema.keys,
29
 }
29
 }
30
 
30
 
31
 module.exports = {
31
 module.exports = {
60
 
60
 
61
         /** Validate the server response */
61
         /** Validate the server response */
62
         response: {
62
         response: {
63
-            schema: apiSchema.single.append({
64
-                data: responseSchemas.response
65
-            }).label('response_list_res'),
63
+            schema: apiSchema.single
64
+                .append({
65
+                    data: responseSchemas.response,
66
+                })
67
+                .label('response_list_res'),
66
             failAction: 'log',
68
             failAction: 'log',
67
         },
69
         },
68
     },
70
     },

+ 1
- 1
backend/lib/routes/user/create-profile.js Wyświetl plik

36
         user_id: Joi.number(),
36
         user_id: Joi.number(),
37
         user_name: Joi.string(),
37
         user_name: Joi.string(),
38
     }).label('created_profile'),
38
     }).label('created_profile'),
39
-    error: errorSchema.single
39
+    error: errorSchema.single,
40
 }
40
 }
41
 
41
 
42
 module.exports = {
42
 module.exports = {

+ 1
- 1
backend/lib/routes/user/list-profiles.js Wyświetl plik

28
 
28
 
29
 const responseSchemas = {
29
 const responseSchemas = {
30
     profilesList: profileSchema.list,
30
     profilesList: profileSchema.list,
31
-    error: errorSchema.single
31
+    error: errorSchema.single,
32
 }
32
 }
33
 
33
 
34
 module.exports = {
34
 module.exports = {

+ 3
- 1
backend/lib/routes/user/login.js Wyświetl plik

18
         payload: Joi.object({
18
         payload: Joi.object({
19
             user: userSchema.single,
19
             user: userSchema.single,
20
             error: errorSchema.single,
20
             error: errorSchema.single,
21
-        }).append().label('login_payload'),
21
+        })
22
+            .append()
23
+            .label('login_payload'),
22
     },
24
     },
23
     user: userSchema.single,
25
     user: userSchema.single,
24
 }
26
 }

+ 4
- 4
backend/lib/routes/user/signup.js Wyświetl plik

14
 
14
 
15
 const validators = {
15
 const validators = {
16
     post: {
16
     post: {
17
-        payload: userSchema.userSignup
18
-    }
17
+        payload: userSchema.userSignup,
18
+    },
19
 }
19
 }
20
 
20
 
21
 const responseSchemas = {
21
 const responseSchemas = {
27
         is_admin: Joi.number(),
27
         is_admin: Joi.number(),
28
         is_verified: Joi.number(),
28
         is_verified: Joi.number(),
29
     }).label('created_user'),
29
     }).label('created_user'),
30
-    error: errorSchema.single
30
+    error: errorSchema.single,
31
 }
31
 }
32
 
32
 
33
 module.exports = {
33
 module.exports = {
55
                         is_poster: userType,
55
                         is_poster: userType,
56
                         is_admin: 0,
56
                         is_admin: 0,
57
                         is_verified: 0,
57
                         is_verified: 0,
58
-                    }
58
+                    },
59
                 })
59
                 })
60
                 return h
60
                 return h
61
                     .response({
61
                     .response({

+ 1
- 0
backend/lib/services/matchqueue.js Wyświetl plik

39
         })
39
         })
40
         return queueByProfileId
40
         return queueByProfileId
41
     }
41
     }
42
+
42
     /**
43
     /**
43
      * Saves Scored Profile Ids to MatchQue IN ORDER
44
      * Saves Scored Profile Ids to MatchQue IN ORDER
44
      * @param {number} profileId
45
      * @param {number} profileId

+ 21
- 12
backend/lib/services/notification.js Wyświetl plik

17
     const endl = '\r\n'
17
     const endl = '\r\n'
18
     for (const i in event) {
18
     for (const i in event) {
19
         let val = event[i]
19
         let val = event[i]
20
-        if (val instanceof Buffer) { val = val.toString() }
21
-        if (typeof val === 'object') { val = JSON.stringify(val) }
20
+        if (val instanceof Buffer) {
21
+            val = val.toString()
22
+        }
23
+        if (typeof val === 'object') {
24
+            val = JSON.stringify(val)
25
+        }
22
         str += i + ': ' + val + endl
26
         str += i + ': ' + val + endl
23
     }
27
     }
24
     str += endl
28
     str += endl
29
  * Transform extension
33
  * Transform extension
30
  * ?: I don't really get what this is doing
34
  * ?: I don't really get what this is doing
31
  * @param {object} options
35
  * @param {object} options
32
- * @param {object} objectMode 
36
+ * @param {object} objectMode
33
  */
37
  */
34
 class Transformer extends Transform {
38
 class Transformer extends Transform {
35
     constructor(options, objectMode) {
39
     constructor(options, objectMode) {
37
         options = options || {}
41
         options = options || {}
38
         this.counter = 1
42
         this.counter = 1
39
         this.event = options.event || null
43
         this.event = options.event || null
40
-        this.generateId = options.generateId ? options.generateId : () => {
41
-            return this.counter++
42
-        }
44
+        this.generateId = options.generateId
45
+            ? options.generateId
46
+            : () => {
47
+                  return this.counter++
48
+              }
43
     }
49
     }
44
-    _transform (chunk, encoding, callback) {
50
+    _transform(chunk, encoding, callback) {
45
         const event = {
51
         const event = {
46
             id: this.generateId(chunk),
52
             id: this.generateId(chunk),
47
-            data: chunk
53
+            data: chunk,
54
+        }
55
+        if (this.event) {
56
+            event.event = this.event
48
         }
57
         }
49
-        if (this.event) { event.event = this.event }
50
         this.push(stringifyEvent(event))
58
         this.push(stringifyEvent(event))
51
         callback()
59
         callback()
52
     }
60
     }
54
         this.push(stringifyEvent(ENDER))
62
         this.push(stringifyEvent(ENDER))
55
         callback()
63
         callback()
56
     }
64
     }
57
-} 
65
+}
58
 
66
 
59
 /**
67
 /**
60
  * Take an event stream and write content to another stream
68
  * Take an event stream and write content to another stream
95
         //     event.pipe(stream)
103
         //     event.pipe(stream)
96
         // }
104
         // }
97
         console.log('streamOptions :', streamOptions)
105
         console.log('streamOptions :', streamOptions)
98
-        return h.response(active)
106
+        return h
107
+            .response(active)
99
             .header('content-type', 'text/event-stream')
108
             .header('content-type', 'text/event-stream')
100
             .header('content-encoding', 'identity')
109
             .header('content-encoding', 'identity')
101
     }
110
     }
116
     // internals.writeEvent(event, active)
125
     // internals.writeEvent(event, active)
117
 }
126
 }
118
 
127
 
119
-module.exports = { onEvent }
128
+module.exports = { onEvent }

+ 27
- 18
backend/lib/services/profile/index.js Wyświetl plik

82
             // CHECKTHIS: Added this because we added user.user_name to CompleteProfile
82
             // CHECKTHIS: Added this because we added user.user_name to CompleteProfile
83
             // so without this, we get undefined user_name
83
             // so without this, we get undefined user_name
84
             .withGraphFetched('user')
84
             .withGraphFetched('user')
85
-        
86
-        return profiler.makeCompleteProfilesFromProfile(profilesEntries, type, this.tagLookup)
85
+
86
+        return profiler.makeCompleteProfilesFromProfile(
87
+            profilesEntries,
88
+            type,
89
+            this.tagLookup,
90
+        )
87
     }
91
     }
88
 
92
 
89
     async getProfilesFor(profileIdArray, type, includeResponses = true) {
93
     async getProfilesFor(profileIdArray, type, includeResponses = true) {
106
             profilesEntries,
110
             profilesEntries,
107
             type,
111
             type,
108
             includeResponses,
112
             includeResponses,
109
-            this.tagLookup
113
+            this.tagLookup,
110
         )
114
         )
111
     }
115
     }
112
 
116
 
128
              * Using using the input and converting to index
132
              * Using using the input and converting to index
129
              * of the generated possible prescore array in config
133
              * of the generated possible prescore array in config
130
              * DUPLICATE:See saveResponseForProfile() line 343
134
              * DUPLICATE:See saveResponseForProfile() line 343
131
-             */ 
135
+             */
132
             let convertedResponse = responseToSave
136
             let convertedResponse = responseToSave
133
-            if(scoring._isScorableResponse(responseToSave.response_key_id)) {
137
+            if (scoring._isScorableResponse(responseToSave.response_key_id)) {
134
                 // Convert -3 to 0, 0 to 3, 3 to 6
138
                 // Convert -3 to 0, 0 to 3, 3 to 6
135
                 const offset = (config.scoreVals.length - 1) / 2
139
                 const offset = (config.scoreVals.length - 1) / 2
136
                 const indexFromInput = parseInt(responseToSave.val) + offset
140
                 const indexFromInput = parseInt(responseToSave.val) + offset
137
-                convertedResponse.val = config.scoreVals[indexFromInput].toString()
141
+                convertedResponse.val =
142
+                    config.scoreVals[indexFromInput].toString()
138
             }
143
             }
139
 
144
 
140
             const responseInfo = {
145
             const responseInfo = {
194
         )
199
         )
195
         if (matchingResponses.length > 0) {
200
         if (matchingResponses.length > 0) {
196
             const alreadyAnswered = matchingResponses.map(
201
             const alreadyAnswered = matchingResponses.map(
197
-                matchingRes => matchingRes.response_key_id
202
+                matchingRes => matchingRes.response_key_id,
198
             )
203
             )
199
             await Response.query()
204
             await Response.query()
200
                 .where({ profile_id: profileId })
205
                 .where({ profile_id: profileId })
206
          * Convert indexes to actual score values
211
          * Convert indexes to actual score values
207
          * Using using the input and converting to index
212
          * Using using the input and converting to index
208
          * of the generated possible prescore array in config
213
          * of the generated possible prescore array in config
209
-         */ 
214
+         */
210
         let convertedResponse = responseToSave
215
         let convertedResponse = responseToSave
211
-        if(scoring._isScorableResponse(responseToSave.response_key_id)) {
216
+        if (scoring._isScorableResponse(responseToSave.response_key_id)) {
212
             // Convert -3 to 0, 0 to 3, 3 to 6
217
             // Convert -3 to 0, 0 to 3, 3 to 6
213
             const offset = (config.scoreVals.length - 1) / 2
218
             const offset = (config.scoreVals.length - 1) / 2
214
             const indexFromInput = parseInt(responseToSave.val) + offset
219
             const indexFromInput = parseInt(responseToSave.val) + offset
251
             .findOne('profile_id', profileId)
256
             .findOne('profile_id', profileId)
252
             .withGraphFetched('responses')
257
             .withGraphFetched('responses')
253
             .withGraphFetched('user')
258
             .withGraphFetched('user')
254
-        
259
+
255
         // Move unneeded responses
260
         // Move unneeded responses
256
         const userZip = zipcoder.getZipCodeFromProfile(userProfile)
261
         const userZip = zipcoder.getZipCodeFromProfile(userProfile)
257
 
262
 
263
 
268
 
264
         // TODO: Let Objection optimize this
269
         // TODO: Let Objection optimize this
265
         const isPosterOpposite = userProfile.user.is_poster == 1 ? 0 : 1
270
         const isPosterOpposite = userProfile.user.is_poster == 1 ? 0 : 1
266
-        profileIdsOfOppositeType = profileIdsOfOppositeType.filter(profile => {
267
-            return profile.user.is_poster == isPosterOpposite
268
-        }).filter(profile => {
269
-            // Only include profiles that included zipcode response
270
-            return zipcoder.getZipCodeFromProfile(profile) ? true : false
271
-        })
272
-        
271
+        profileIdsOfOppositeType = profileIdsOfOppositeType
272
+            .filter(profile => {
273
+                return profile.user.is_poster == isPosterOpposite
274
+            })
275
+            .filter(profile => {
276
+                // Only include profiles that included zipcode response
277
+                return zipcoder.getZipCodeFromProfile(profile) ? true : false
278
+            })
279
+
273
         const profilePlusDistance = await Promise.all(
280
         const profilePlusDistance = await Promise.all(
274
             profileIdsOfOppositeType.map(async profile => {
281
             profileIdsOfOppositeType.map(async profile => {
275
                 const targetZip = zipcoder.getZipCodeFromProfile(profile)
282
                 const targetZip = zipcoder.getZipCodeFromProfile(profile)
315
             'zip_code_id',
322
             'zip_code_id',
316
             parseInt(zipCode),
323
             parseInt(zipCode),
317
         )
324
         )
318
-        if (!zipInfo) { console.error('zip:', zipCode) }
325
+        if (!zipInfo) {
326
+            console.error('zip:', zipCode)
327
+        }
319
         return {
328
         return {
320
             latitude: parseFloat(zipInfo.latitude),
329
             latitude: parseFloat(zipInfo.latitude),
321
             longitude: parseFloat(zipInfo.longitude),
330
             longitude: parseFloat(zipInfo.longitude),

+ 34
- 10
backend/lib/services/profile/profiler.js Wyświetl plik

33
             // [] of all "profile" responses
33
             // [] of all "profile" responses
34
             this.responses = profile.responses
34
             this.responses = profile.responses
35
             // image, language, duration, presence, blurb, urgency, role, pronouns, distance
35
             // image, language, duration, presence, blurb, urgency, role, pronouns, distance
36
-            const prefs = ['zipcode', 'duration', 'presence', 'urgency', 'role', 'pronouns', 'distance']
36
+            const prefs = [
37
+                'zipcode',
38
+                'duration',
39
+                'presence',
40
+                'urgency',
41
+                'role',
42
+                'pronouns',
43
+                'distance',
44
+            ]
37
             const prefsKeys = config.prefKeys
45
             const prefsKeys = config.prefKeys
38
             prefs.forEach((pref, i) => {
46
             prefs.forEach((pref, i) => {
39
                 this.profile_prefs[pref] = this.responses.filter(
47
                 this.profile_prefs[pref] = this.responses.filter(
40
-                    r => r.response_key_id === prefsKeys[i]
48
+                    r => r.response_key_id === prefsKeys[i],
41
                 )[0]
49
                 )[0]
42
             })
50
             })
43
-            this.profile_description = this.responses.filter(r => r.response_key_id === config.blurbKey).map(r => r.val)[0]
44
-            this.profile_media = this.responses.filter(r => r.response_key_id === config.mediaKey).map(r => r.val)
45
-            this.profile_languages = this.responses.filter(r => r.response_key_id === config.langKey).map(r => r.val)
51
+            this.profile_description = this.responses
52
+                .filter(r => r.response_key_id === config.blurbKey)
53
+                .map(r => r.val)[0]
54
+            this.profile_media = this.responses
55
+                .filter(r => r.response_key_id === config.mediaKey)
56
+                .map(r => r.val)
57
+            this.profile_languages = this.responses
58
+                .filter(r => r.response_key_id === config.langKey)
59
+                .map(r => r.val)
46
         }
60
         }
47
     }
61
     }
48
 }
62
 }
49
 
63
 
50
-const makeCompleteProfiles = (profileIdArray, profilesEntries, type, includeResponses, tagLookup) => {
64
+const makeCompleteProfiles = (
65
+    profileIdArray,
66
+    profilesEntries,
67
+    type,
68
+    includeResponses,
69
+    tagLookup,
70
+) => {
51
     const completeProfiles = []
71
     const completeProfiles = []
52
     profileIdArray.forEach(pid => {
72
     profileIdArray.forEach(pid => {
53
         profilesEntries.forEach(entry => {
73
         profilesEntries.forEach(entry => {
54
             if (entry.profile_id == pid) {
74
             if (entry.profile_id == pid) {
55
-                const complete = new CompleteProfile(entry, type, includeResponses)
75
+                const complete = new CompleteProfile(
76
+                    entry,
77
+                    type,
78
+                    includeResponses,
79
+                )
56
                 tagger.setProfileTags(entry, complete, tagLookup)
80
                 tagger.setProfileTags(entry, complete, tagLookup)
57
                 completeProfiles.push(complete)
81
                 completeProfiles.push(complete)
58
             }
82
             }
60
     })
84
     })
61
     return completeProfiles
85
     return completeProfiles
62
 }
86
 }
63
-const makeCompleteProfilesFromProfile = (profilesEntries, type, tagLookup)=> {
87
+const makeCompleteProfilesFromProfile = (profilesEntries, type, tagLookup) => {
64
     profilesEntries.forEach(profile => {
88
     profilesEntries.forEach(profile => {
65
         tagger.setProfileTags(profile, profile, tagLookup)
89
         tagger.setProfileTags(profile, profile, tagLookup)
66
     })
90
     })
74
 module.exports = {
98
 module.exports = {
75
     CompleteProfile,
99
     CompleteProfile,
76
     makeCompleteProfiles,
100
     makeCompleteProfiles,
77
-    makeCompleteProfilesFromProfile
78
-}
101
+    makeCompleteProfilesFromProfile,
102
+}

+ 7
- 7
backend/lib/services/profile/scorer.js Wyświetl plik

20
 
20
 
21
 const _isScorableResponse = res_key_id => {
21
 const _isScorableResponse = res_key_id => {
22
     let isScorable = false
22
     let isScorable = false
23
-    if(config.resKeys.includes(res_key_id)) {
23
+    if (config.resKeys.includes(res_key_id)) {
24
         isScorable = true
24
         isScorable = true
25
     }
25
     }
26
     return isScorable
26
     return isScorable
32
             error: `complete responses for profile: ${seeker.profile_id} unqeual to profile: ${potentialMatch.profile_id} | ${seeker.responses.length}:${potentialMatch.responses.length}`,
32
             error: `complete responses for profile: ${seeker.profile_id} unqeual to profile: ${potentialMatch.profile_id} | ${seeker.responses.length}:${potentialMatch.responses.length}`,
33
         }
33
         }
34
 
34
 
35
-    const aRes = seeker.responses.filter(
36
-        res =>  _isScorableResponse(res.response_key_id)
35
+    const aRes = seeker.responses.filter(res =>
36
+        _isScorableResponse(res.response_key_id),
37
     )
37
     )
38
-    const bRes = potentialMatch.responses.filter(
39
-        res =>  _isScorableResponse(res.response_key_id)
38
+    const bRes = potentialMatch.responses.filter(res =>
39
+        _isScorableResponse(res.response_key_id),
40
     )
40
     )
41
 
41
 
42
     const composite = []
42
     const composite = []
72
     _isScorableResponse,
72
     _isScorableResponse,
73
     scoreResponses,
73
     scoreResponses,
74
     makeScoreLookup,
74
     makeScoreLookup,
75
-    scoreAll
76
-}
75
+    scoreAll,
76
+}

+ 2
- 2
backend/lib/services/profile/tagger.js Wyświetl plik

3
 }
3
 }
4
 
4
 
5
 module.exports = {
5
 module.exports = {
6
-    setProfileTags
7
-}
6
+    setProfileTags,
7
+}

+ 3
- 3
backend/lib/services/profile/zipcoder.js Wyświetl plik

6
 const getZipCodeFromProfile = profile => {
6
 const getZipCodeFromProfile = profile => {
7
     // There should only be one zip code entry per profile
7
     // There should only be one zip code entry per profile
8
     let zipRes = profile.responses.find(
8
     let zipRes = profile.responses.find(
9
-        res => res.response_key_id == config.zipcodeKey
9
+        res => res.response_key_id == config.zipcodeKey,
10
     )
10
     )
11
     return zipRes.val
11
     return zipRes.val
12
 }
12
 }
21
 
21
 
22
 module.exports = {
22
 module.exports = {
23
     getZipCodeFromProfile,
23
     getZipCodeFromProfile,
24
-    filterByDistance
25
-}
24
+    filterByDistance,
25
+}

+ 5
- 2
backend/lib/services/user.js Wyświetl plik

58
      */
58
      */
59
     async signup({ password, userInfo }, txn) {
59
     async signup({ password, userInfo }, txn) {
60
         const { User } = this.server.models()
60
         const { User } = this.server.models()
61
-        const matchingEmails = await User.query().where('user_email', userInfo.user_email)
61
+        const matchingEmails = await User.query().where(
62
+            'user_email',
63
+            userInfo.user_email,
64
+        )
62
 
65
 
63
-        if(matchingEmails.length > 0) { 
66
+        if (matchingEmails.length > 0) {
64
             throw `User ${userInfo.user_email} already exists: Cannot create a user without a unique email`
67
             throw `User ${userInfo.user_email} already exists: Cannot create a user without a unique email`
65
         }
68
         }
66
         const user = await User.query(txn).insert(userInfo)
69
         const user = await User.query(txn).insert(userInfo)

+ 2
- 2
backend/server/index.js Wyświetl plik

25
 if (require.main === module) {
25
 if (require.main === module) {
26
     exports.deployment({ start: true })
26
     exports.deployment({ start: true })
27
 
27
 
28
-    process.on('unhandledRejection', (err) => {
28
+    process.on('unhandledRejection', err => {
29
         throw err
29
         throw err
30
     })
30
     })
31
-}
31
+}

frontend/.eslintrc.json → frontend/.eslintrc Wyświetl plik


frontend/.prettierrc.json → frontend/.prettierrc Wyświetl plik

10
     "pugFramework": "vue",
10
     "pugFramework": "vue",
11
     "pugSingleFileComponentIndentation": false,
11
     "pugSingleFileComponentIndentation": false,
12
     "pugClassNotation": "literal"
12
     "pugClassNotation": "literal"
13
-}
13
+}

+ 40
- 50
frontend/src/App.vue Wyświetl plik

1
 <template lang="pug">
1
 <template lang="pug">
2
-SideBar(
3
-    v-if="showSidebar"
4
-    :pid="getPid"
5
-    @updatePid="setPid"
6
-    @hide="showSidebar = false"
7
-)
8
-RouterView(
9
-    :pid="getPid"
10
-    @updatePid="setPid"
11
-    @show-sidebar="showSidebar = !showSidebar"
12
-)
2
+w-app
3
+    w-button My Button
4
+    SideBar(
5
+        v-if="showSidebar"
6
+        :pid="getPid"
7
+        @updatePid="setPid"
8
+        @hide="showSidebar = false"
9
+    )
10
+    RouterView(
11
+        :pid="getPid"
12
+        @updatePid="setPid"
13
+        @show-sidebar="showSidebar = !showSidebar"
14
+    )
13
 </template>
15
 </template>
14
 
16
 
15
 <script>
17
 <script>
26
 export default {
28
 export default {
27
     components: { SideBar },
29
     components: { SideBar },
28
     data: () => ({
30
     data: () => ({
29
-        showSidebar: false
31
+        showSidebar: false,
30
     }),
32
     }),
31
     computed: {
33
     computed: {
32
-        getPid: () => currentProfile.id.value
34
+        getPid: () => currentProfile.id.value,
33
     },
35
     },
34
     async created() {
36
     async created() {
35
         /** Get questions so we can compare against profile responses */
37
         /** Get questions so we can compare against profile responses */
36
         await surveyFactory.getQuestions()
38
         await surveyFactory.getQuestions()
37
 
39
 
38
-        /** 
40
+        /**
39
          * Development mode turns router guards off so
41
          * Development mode turns router guards off so
40
-         * we hard set the profile id instead of 
42
+         * we hard set the profile id instead of
41
          * using the login form
43
          * using the login form
42
-        */
43
-        if(DEV_MODE) { this.setPid(DEV_PID) }
44
+         */
45
+        if (DEV_MODE) {
46
+            this.setPid(DEV_PID)
47
+        }
44
 
48
 
45
-        if(currentProfile.isLoggedIn) {
49
+        if (currentProfile.isLoggedIn) {
46
             console.warn(`setting up Chatter and Toaster for ${this.getPid}...`)
50
             console.warn(`setting up Chatter and Toaster for ${this.getPid}...`)
47
             this.setupChatter()
51
             this.setupChatter()
48
             this.setupToaster()
52
             this.setupToaster()
74
 </script>
78
 </script>
75
 
79
 
76
 <style lang="postcss">
80
 <style lang="postcss">
81
+/* prettier-ignore */
77
 @import './sss/theme.sss'
82
 @import './sss/theme.sss'
78
 
83
 
79
 #app
84
 #app
80
-    display: flex
81
-    flex-direction: row
82
-    text-align: center
83
-    color: $primary
84
-    font-family: $sans
85
-    background-color: $dark
86
-    overflow-x: hidden
87
     height: 100%
85
     height: 100%
88
-    > main
89
-        position: relative
86
+    flex-direction: row
87
+    .w-app
88
+        display: flex
89
+        text-align: center
90
+        color: $primary
91
+        font-family: $sans
92
+        background-color: $dark
93
+        overflow-x: hidden
90
         height: 100%
94
         height: 100%
91
-        > header
92
-            h2
93
-                font-size: $ms-1
94
-        > article
95
+        > main
96
+            position: relative
95
             height: 100%
97
             height: 100%
96
-            width: 100%
97
-            flex-direction: column
98
-    
99
-    button
100
-        padding: $ms-0
101
-        background-color: $primary
102
-        border: 1px transparent solid
103
-        border-radius: $ms-1
104
-        transition: $transition
105
-        &:hover
106
-            background-color: $secondary
107
-            border: 1px transparent solid
108
-            border-radius: $ms-1
109
-            cursor: pointer
110
-            color: $primary
111
-        &:disabled
112
-            cursor: default
113
-            color: $primary
114
-            background-color: $light
98
+            > header
99
+                h2
100
+                    font-size: $ms-1
101
+            > article
102
+                height: 100%
103
+                width: 100%
104
+                flex-direction: column
115
 </style>
105
 </style>

+ 1
- 0
frontend/src/components/MainNav.vue Wyświetl plik

13
 </script>
13
 </script>
14
 
14
 
15
 <style lang="postcss">
15
 <style lang="postcss">
16
+/* prettier-ignore */
16
 #main-header
17
 #main-header
17
   position: absolute
18
   position: absolute
18
   bottom: 1vh
19
   bottom: 1vh

+ 3
- 4
frontend/src/components/Messages.vue Wyświetl plik

19
 
19
 
20
 export default {
20
 export default {
21
     name: 'ProfileMessages',
21
     name: 'ProfileMessages',
22
-    mixins: [ mixins.pidMixin ],
22
+    mixins: [mixins.pidMixin],
23
     props: {
23
     props: {
24
         matches: {
24
         matches: {
25
             type: [Object, Array],
25
             type: [Object, Array],
26
-            default: () => []
26
+            default: () => [],
27
         },
27
         },
28
     },
28
     },
29
 }
29
 }
30
 </script>
30
 </script>
31
 
31
 
32
 <style lang="postcss">
32
 <style lang="postcss">
33
-
33
+/* prettier-ignore */
34
 .sidebar
34
 .sidebar
35
     &--messages
35
     &--messages
36
         padding: 20px 10px
36
         padding: 20px 10px
68
     &__content
68
     &__content
69
         padding-top: 10px
69
         padding-top: 10px
70
         line-height: 1em
70
         line-height: 1em
71
-        
72
 </style>
71
 </style>

+ 1
- 2
frontend/src/components/ProfileCardList.vue Wyświetl plik

120
 </script>
120
 </script>
121
 
121
 
122
 <style lang="postcss">
122
 <style lang="postcss">
123
+/* prettier-ignore */
123
 .profile-card-list
124
 .profile-card-list
124
     display: flex
125
     display: flex
125
     justify-content: center
126
     justify-content: center
145
             background-color: goldenrod
146
             background-color: goldenrod
146
             nav > button
147
             nav > button
147
                 font-size: 2vw
148
                 font-size: 2vw
148
-
149
-
150
 </style>
149
 </style>

+ 5
- 5
frontend/src/components/SideBar.vue Wyświetl plik

14
 import { mixins } from '../utils'
14
 import { mixins } from '../utils'
15
 
15
 
16
 export default {
16
 export default {
17
-    components: { Messages }, 
18
-    mixins: [ mixins.pidMixin ],
17
+    components: { Messages },
18
+    mixins: [mixins.pidMixin],
19
     data: () => ({
19
     data: () => ({
20
         switchToPID: null,
20
         switchToPID: null,
21
         matches: [
21
         matches: [
36
     mounted() {
36
     mounted() {
37
         // Set the form to display the default pid set in Home.vue
37
         // Set the form to display the default pid set in Home.vue
38
         this.switchToPID = this.pid
38
         this.switchToPID = this.pid
39
-    }
39
+    },
40
 }
40
 }
41
 </script>
41
 </script>
42
 
42
 
43
 <style lang="postcss">
43
 <style lang="postcss">
44
+/* prettier-ignore */
44
 aside.sidebar
45
 aside.sidebar
45
     background-color: yellow
46
     background-color: yellow
46
     height: 100vh
47
     height: 100vh
53
     flex-direction: row
54
     flex-direction: row
54
     input
55
     input
55
         border: 0
56
         border: 0
56
-
57
-</style>
57
+</style>

+ 8
- 7
frontend/src/main.js Wyświetl plik

2
 import router from './router'
2
 import router from './router'
3
 import { checkLoginStatus } from './router/guards'
3
 import { checkLoginStatus } from './router/guards'
4
 
4
 
5
+import WaveUI from 'wave-ui'
6
+
5
 import App from './App.vue'
7
 import App from './App.vue'
6
 import MainNav from './components/MainNav.vue'
8
 import MainNav from './components/MainNav.vue'
7
 
9
 
12
  */
14
  */
13
 router.beforeEach((to, from, next) => {
15
 router.beforeEach((to, from, next) => {
14
     /**
16
     /**
15
-     * Skip any route guarding with `npm run dev`
16
-     */
17
-    if(DEV) { next() }
18
-
19
-    /**
20
-     * Use the loginService to deal with login details
17
+     * Skip any route guarding with `npm run dev` or
18
+     * use the loginService to deal with login details
21
      * Activate with `npm run nodev`
19
      * Activate with `npm run nodev`
22
      */
20
      */
23
-    else {
21
+    if (DEV) {
22
+        next()
23
+    } else {
24
         checkLoginStatus(to, next)
24
         checkLoginStatus(to, next)
25
     }
25
     }
26
 })
26
 })
27
 
27
 
28
 const run = entry => {
28
 const run = entry => {
29
     const siimee = createApp(App).use(router)
29
     const siimee = createApp(App).use(router)
30
+    new WaveUI(siimee, {})
30
     siimee.component('MainNav', MainNav)
31
     siimee.component('MainNav', MainNav)
31
     siimee.mount(entry)
32
     siimee.mount(entry)
32
 }
33
 }

+ 12
- 5
frontend/src/views/HomeView.vue Wyświetl plik

2
 main.view--home.f-col.start.w-full
2
 main.view--home.f-col.start.w-full
3
     header
3
     header
4
         h2 home - profile: {{ pid }}
4
         h2 home - profile: {{ pid }}
5
-
5
+        w-badge
6
+            template(#badge) 3
7
+            w-button(color="primary")
8
+                w-icon(class="mr1") mdi mdi-email
9
+                    Emails
6
     article(v-if="cards.length && !loading")
10
     article(v-if="cards.length && !loading")
7
         ProfileCardList(:profiles="cards" :pid="pid" @reload="getCards")
11
         ProfileCardList(:profiles="cards" :pid="pid" @reload="getCards")
8
 
12
 
20
 
24
 
21
 /** Callback used to format incoming into card */
25
 /** Callback used to format incoming into card */
22
 const convertToCard = profile => {
26
 const convertToCard = profile => {
23
-    if(profile.type !== 'profile') {
27
+    if (profile.type !== 'profile') {
24
         console.error(`Cannot convert ${profile} to Card. Invalid entity.`)
28
         console.error(`Cannot convert ${profile} to Card. Invalid entity.`)
25
     }
29
     }
26
-    if(!profile.isValid()) {
30
+    if (!profile.isValid()) {
27
         console.warn(`Profile ${profile.profile_id} is not a valid profile.`)
31
         console.warn(`Profile ${profile.profile_id} is not a valid profile.`)
28
     }
32
     }
29
     return new Card({
33
     return new Card({
36
 export default {
40
 export default {
37
     name: 'HomeView',
41
     name: 'HomeView',
38
     components: { ProfileCardList },
42
     components: { ProfileCardList },
39
-    mixins: [ mixins.pidMixin, mixins.cardMixin ],
43
+    mixins: [mixins.pidMixin, mixins.cardMixin],
40
     methods: {
44
     methods: {
41
         /** Gets called from cardMixin */
45
         /** Gets called from cardMixin */
42
         async getCards() {
46
         async getCards() {
44
             try {
48
             try {
45
                 const queueList = await fetchQueueByProfileId(this.pid)
49
                 const queueList = await fetchQueueByProfileId(this.pid)
46
                 this.cards = this._reformat(queueList, convertToCard)
50
                 this.cards = this._reformat(queueList, convertToCard)
47
-            } catch (err) { console.error(err) }
51
+            } catch (err) {
52
+                console.error(err)
53
+            }
48
             this.loading = false
54
             this.loading = false
49
         },
55
         },
50
     },
56
     },
52
 </script>
58
 </script>
53
 
59
 
54
 <style lang="postcss">
60
 <style lang="postcss">
61
+/* prettier-ignore */
55
 main
62
 main
56
     position: relative
63
     position: relative
57
     height: 100%
64
     height: 100%

+ 6
- 6
frontend/src/views/LoginView.vue Wyświetl plik

18
 export default {
18
 export default {
19
     data: () => ({
19
     data: () => ({
20
         form: {
20
         form: {
21
-            profileId: null
21
+            profileId: null,
22
         },
22
         },
23
     }),
23
     }),
24
     methods: {
24
     methods: {
25
         async onSubmit() {
25
         async onSubmit() {
26
-            if(!this.form.profileId) console.error('No profile in form')
27
-            
26
+            if (!this.form.profileId) console.error('No profile in form')
27
+
28
             /**
28
             /**
29
              * Default to the HomeView and alter as needed (side-effects!)
29
              * Default to the HomeView and alter as needed (side-effects!)
30
              */
30
              */
31
             const toRoute = { name: 'HomeView' }
31
             const toRoute = { name: 'HomeView' }
32
-            
32
+
33
             /**
33
             /**
34
              * Profile needs a complete survey and
34
              * Profile needs a complete survey and
35
              * alters the url if it's incomplete
35
              * alters the url if it's incomplete
36
              */
36
              */
37
             const alreadyLoggedIn = await currentProfile.isLoggedIn
37
             const alreadyLoggedIn = await currentProfile.isLoggedIn
38
-            if(!alreadyLoggedIn) {
38
+            if (!alreadyLoggedIn) {
39
                 await currentProfile.login(this.form.profileId)
39
                 await currentProfile.login(this.form.profileId)
40
             }
40
             }
41
 
41
 
46
 </script>
46
 </script>
47
 
47
 
48
 <style lang="postcss">
48
 <style lang="postcss">
49
-
49
+/* prettier-ignore */
50
 </style>
50
 </style>

+ 7
- 4
frontend/src/views/MatchesView.vue Wyświetl plik

20
 
20
 
21
 /** Callback used to format incoming into card */
21
 /** Callback used to format incoming into card */
22
 const convertToCard = grouping => {
22
 const convertToCard = grouping => {
23
-    if(grouping.type !== 'grouping') {
23
+    if (grouping.type !== 'grouping') {
24
         console.error(`Cannot convert ${grouping} to Card. Invalid entity.`)
24
         console.error(`Cannot convert ${grouping} to Card. Invalid entity.`)
25
     }
25
     }
26
-    if(!grouping.profile.isValid()) {
26
+    if (!grouping.profile.isValid()) {
27
         console.warn(`Profile in ${grouping} is not a valid profile.`)
27
         console.warn(`Profile in ${grouping} is not a valid profile.`)
28
     }
28
     }
29
     return new Card({
29
     return new Card({
36
 export default {
36
 export default {
37
     name: 'MatchView',
37
     name: 'MatchView',
38
     components: { ProfileCardList },
38
     components: { ProfileCardList },
39
-    mixins: [ mixins.pidMixin, mixins.cardMixin ],
39
+    mixins: [mixins.pidMixin, mixins.cardMixin],
40
     methods: {
40
     methods: {
41
         /** Gets called from cardMixin */
41
         /** Gets called from cardMixin */
42
         async getCards() {
42
         async getCards() {
44
             try {
44
             try {
45
                 const matchList = await fetchMembershipsByProfileId(this.pid)
45
                 const matchList = await fetchMembershipsByProfileId(this.pid)
46
                 this.cards = this._reformat(matchList, convertToCard)
46
                 this.cards = this._reformat(matchList, convertToCard)
47
-            } catch (err) { console.error(err) }
47
+            } catch (err) {
48
+                console.error(err)
49
+            }
48
             this.loading = false
50
             this.loading = false
49
         },
51
         },
50
     },
52
     },
52
 </script>
54
 </script>
53
 
55
 
54
 <style lang="postcss">
56
 <style lang="postcss">
57
+/* prettier-ignore */
55
 .row
58
 .row
56
     display: flex
59
     display: flex
57
     flex-direction: row
60
     flex-direction: row

+ 3
- 1
frontend/src/views/ProfileView.vue Wyświetl plik

61
 }
61
 }
62
 </script>
62
 </script>
63
 
63
 
64
-<style lang="postcss"></style>
64
+<style lang="postcss">
65
+/* prettier-ignore */
66
+</style>

+ 63
- 26
frontend/src/views/SurveyView.vue Wyświetl plik

61
 import { surveyFactory, randomSurveyResponses } from '@/utils'
61
 import { surveyFactory, randomSurveyResponses } from '@/utils'
62
 import { allSteps, aspectResponses, possible } from '@/utils/lang'
62
 import { allSteps, aspectResponses, possible } from '@/utils/lang'
63
 
63
 
64
-import { currentProfile, createProfileForUserId, fetchProfileByProfileId, scoreSurveyByProfileId, signupUser } from '@/services'
64
+import {
65
+    currentProfile,
66
+    createProfileForUserId,
67
+    fetchProfileByProfileId,
68
+    scoreSurveyByProfileId,
69
+    signupUser,
70
+} from '@/services'
65
 
71
 
66
 import { maxDistanceKey } from '../../../backend/db/data-generator/config.json'
72
 import { maxDistanceKey } from '../../../backend/db/data-generator/config.json'
67
 
73
 
86
                 honesty: 0,
92
                 honesty: 0,
87
                 respect: 0,
93
                 respect: 0,
88
             },
94
             },
89
-            aspectResponses: Object.values(aspectResponses.usa)
95
+            aspectResponses: Object.values(aspectResponses.usa),
90
         }
96
         }
91
     },
97
     },
92
     computed: {
98
     computed: {
116
             toGen.forEach(async () => {
122
             toGen.forEach(async () => {
117
                 const randRes = randomSurveyResponses(this.bypassCount)
123
                 const randRes = randomSurveyResponses(this.bypassCount)
118
                 randRes.forEach((tr, i) => {
124
                 randRes.forEach((tr, i) => {
119
-                    this.storeResponseLike(i, tr.idOrPrompt, tr.idOrPrompt, tr.val)
125
+                    this.storeResponseLike(
126
+                        i,
127
+                        tr.idOrPrompt,
128
+                        tr.idOrPrompt,
129
+                        tr.val,
130
+                    )
120
                 })
131
                 })
121
                 this.bypassCount++
132
                 this.bypassCount++
122
                 await this.onSave()
133
                 await this.onSave()
128
             // Also update the form model state for now
139
             // Also update the form model state for now
129
             // We probably can refactor this out
140
             // We probably can refactor this out
130
             this.profile[prompt] = val
141
             this.profile[prompt] = val
131
-            
142
+
132
             /**
143
             /**
133
              * If NO response id is present, that means the answer
144
              * If NO response id is present, that means the answer
134
              * is required and associated with a User and NOT a Profile
145
              * is required and associated with a User and NOT a Profile
135
              **/
146
              **/
136
             this.responseLikes[`step-${step}`] = {
147
             this.responseLikes[`step-${step}`] = {
137
                 idOrPrompt: id ? id : prompt,
148
                 idOrPrompt: id ? id : prompt,
138
-                val: val.toString()
149
+                val: val.toString(),
139
             }
150
             }
140
         },
151
         },
141
         _formatIntoResponses(survey) {
152
         _formatIntoResponses(survey) {
147
         },
158
         },
148
         /**
159
         /**
149
          * Survey responses have User information
160
          * Survey responses have User information
150
-         * mixed in with scoring information so we 
161
+         * mixed in with scoring information so we
151
          * need to separate them
162
          * need to separate them
152
          * @param {array} responseLikes answered by the survey
163
          * @param {array} responseLikes answered by the survey
153
          */
164
          */
155
             let survey = []
166
             let survey = []
156
             const user = {}
167
             const user = {}
157
             responseLikes.forEach(resLike => {
168
             responseLikes.forEach(resLike => {
158
-                if(resLike.idOrPrompt && Number.isFinite(parseInt(resLike.idOrPrompt))) {
169
+                if (
170
+                    resLike.idOrPrompt &&
171
+                    Number.isFinite(parseInt(resLike.idOrPrompt))
172
+                ) {
159
                     survey.push(resLike)
173
                     survey.push(resLike)
160
                 } else {
174
                 } else {
161
                     user[resLike.idOrPrompt] = resLike.val
175
                     user[resLike.idOrPrompt] = resLike.val
166
         async _createUserProfileRel(user, survey) {
180
         async _createUserProfileRel(user, survey) {
167
             /** A User is required before creating a profile */
181
             /** A User is required before creating a profile */
168
             const createdUser = await signupUser(user)
182
             const createdUser = await signupUser(user)
169
-            if(!createdUser) return
183
+            if (!createdUser) return
170
 
184
 
171
-            const userProfileRel = await createProfileForUserId(createdUser.user_id, survey)
172
-            if(!userProfileRel) return 
185
+            const userProfileRel = await createProfileForUserId(
186
+                createdUser.user_id,
187
+                survey,
188
+            )
189
+            if (!userProfileRel) return
173
 
190
 
174
             return userProfileRel
191
             return userProfileRel
175
         },
192
         },
176
         async _getProfileWithScore(createdProfileId, maxDistance) {
193
         async _getProfileWithScore(createdProfileId, maxDistance) {
177
             /** A Profile is associated with n:1 user and referenced by profile id */
194
             /** A Profile is associated with n:1 user and referenced by profile id */
178
-            const fetchedProfile = await fetchProfileByProfileId(createdProfileId)
179
-            if(!fetchedProfile) {
180
-                console.error(`Could not fetch Profile ${createdProfileId}. Please check that a User and Profile were created.`)
195
+            const fetchedProfile = await fetchProfileByProfileId(
196
+                createdProfileId,
197
+            )
198
+            if (!fetchedProfile) {
199
+                console.error(
200
+                    `Could not fetch Profile ${createdProfileId}. Please check that a User and Profile were created.`,
201
+                )
181
                 return
202
                 return
182
             }
203
             }
183
 
204
 
184
             /** Use profile answers to compare against other profile answers */
205
             /** Use profile answers to compare against other profile answers */
185
-            const scored = await scoreSurveyByProfileId(createdProfileId, maxDistance)
186
-            if(!scored) {
206
+            const scored = await scoreSurveyByProfileId(
207
+                createdProfileId,
208
+                maxDistance,
209
+            )
210
+            if (!scored) {
187
                 console.error(`Could not score Profile ${createdProfileId}.`)
211
                 console.error(`Could not score Profile ${createdProfileId}.`)
188
                 return
212
                 return
189
             }
213
             }
191
         },
215
         },
192
         async _setLoginForProfile(profile) {
216
         async _setLoginForProfile(profile) {
193
             const currentId = currentProfile.login(profile.profile_id)
217
             const currentId = currentProfile.login(profile.profile_id)
194
-            if(currentId && profile.responses.length) {
218
+            if (currentId && profile.responses.length) {
195
                 // Stores responses without fetching again
219
                 // Stores responses without fetching again
196
                 currentProfile.setResponses(profile.responses)
220
                 currentProfile.setResponses(profile.responses)
197
             }
221
             }
198
-            if(!currentProfile.isComplete) {
199
-                console.error(`Profile ${currentProfile.id} is incomplete. Please make sure all survey questions have been answered.`)
222
+            if (!currentProfile.isComplete) {
223
+                console.error(
224
+                    `Profile ${currentProfile.id} is incomplete. Please make sure all survey questions have been answered.`,
225
+                )
200
                 return
226
                 return
201
             }
227
             }
202
         },
228
         },
203
         async onSave() {
229
         async onSave() {
204
-            const [ user, survey] = this._separateUserInfoFromResponses(Object.values(this.responseLikes))
205
-            const maxDistanceRes = survey.find(res => res.response_key_id == maxDistanceKey)
230
+            const [user, survey] = this._separateUserInfoFromResponses(
231
+                Object.values(this.responseLikes),
232
+            )
233
+            const maxDistanceRes = survey.find(
234
+                res => res.response_key_id == maxDistanceKey,
235
+            )
206
             /**
236
             /**
207
              * Creating a profile only returns the created
237
              * Creating a profile only returns the created
208
              * user id and profile id
238
              * user id and profile id
209
              **/
239
              **/
210
-            const userProfileRel = await this._createUserProfileRel(user, survey)
240
+            const userProfileRel = await this._createUserProfileRel(
241
+                user,
242
+                survey,
243
+            )
211
             const createdProfileId = userProfileRel.profile_id
244
             const createdProfileId = userProfileRel.profile_id
212
 
245
 
213
             /** A Profile is associated with n:1 user and referenced by profile id */
246
             /** A Profile is associated with n:1 user and referenced by profile id */
214
-            const fetchedProfile = await this._getProfileWithScore(createdProfileId, maxDistanceRes.val)
215
-            
216
-            /** 
247
+            const fetchedProfile = await this._getProfileWithScore(
248
+                createdProfileId,
249
+                maxDistanceRes.val,
250
+            )
251
+
252
+            /**
217
              * Login only after there is a user and
253
              * Login only after there is a user and
218
              * that user has a profile and all responses
254
              * that user has a profile and all responses
219
-            */
255
+             */
220
             this._setLoginForProfile(fetchedProfile)
256
             this._setLoginForProfile(fetchedProfile)
221
-            
257
+
222
             this.$router.push({ name: 'HomeView' })
258
             this.$router.push({ name: 'HomeView' })
223
         },
259
         },
224
         back(prompt) {
260
         back(prompt) {
230
 </script>
266
 </script>
231
 
267
 
232
 <style lang="postcss">
268
 <style lang="postcss">
269
+/* prettier-ignore */
233
 .slide-up
270
 .slide-up
234
     &-leave, &-enter
271
     &-leave, &-enter
235
         &-active
272
         &-active

+ 7
- 0
frontend/vite.config.js Wyświetl plik

9
             '@': require('path').resolve(__dirname, 'src'),
9
             '@': require('path').resolve(__dirname, 'src'),
10
         },
10
         },
11
     },
11
     },
12
+    css: {
13
+        preprocessorOptions: {
14
+            scss: {
15
+                additionalData: '$use-layout-classes: false;@import "/src/../node_modules/wave-ui/src/wave-ui/scss/_variables.scss";',
16
+            },
17
+        },
18
+    },
12
 })
19
 })

Ładowanie…
Anuluj
Zapisz