|
|
@@ -43,17 +43,16 @@ const scoreAll = (profileList, userProfile) => {
|
|
43
|
43
|
* Grab the zip code string
|
|
44
|
44
|
*/
|
|
45
|
45
|
const getZipCodeFromProfile = profile => {
|
|
46
|
|
- // console.log('profile getZipCode', profile)
|
|
47
|
46
|
// There should only be one zip code entry per profile
|
|
48
|
47
|
let zipRes = profile.responses.filter(
|
|
49
|
48
|
// Whatever the zipcode questions is
|
|
50
|
49
|
response => response.response_key_id == zipcodeKey,
|
|
51
|
50
|
)[0]
|
|
|
51
|
+
|
|
52
|
52
|
const responseIndexForZip = profile.responses.indexOf(zipRes)
|
|
53
|
53
|
if (responseIndexForZip >= 0) {
|
|
54
|
54
|
profile.responses.splice(responseIndexForZip, 1)
|
|
55
|
55
|
}
|
|
56
|
|
- // console.log(zipRes)
|
|
57
|
56
|
return zipRes.val
|
|
58
|
57
|
}
|
|
59
|
58
|
|
|
|
@@ -202,9 +201,14 @@ module.exports = class ProfileService extends Schmervice.Service {
|
|
202
|
201
|
response.response_key_id == responseToSave.response_key_id,
|
|
203
|
202
|
)
|
|
204
|
203
|
|
|
|
204
|
+ // Delete matches
|
|
205
|
205
|
// ?:Maybe bad idea
|
|
206
|
206
|
if (matchingResponses.length > 0) {
|
|
207
|
|
- return null
|
|
|
207
|
+ const alreadyAnswered = matchingResponses.map(matchingRes => matchingRes.response_key_id)
|
|
|
208
|
+ await Response.query()
|
|
|
209
|
+ .where({ profile_id: profileId })
|
|
|
210
|
+ .delete()
|
|
|
211
|
+ .whereIn('response_key_id', alreadyAnswered)
|
|
208
|
212
|
}
|
|
209
|
213
|
|
|
210
|
214
|
await Response.query().insert(responseToSave)
|