Parcourir la source

:bug: Addressed bugs involving validation and groupings

juan-filtering-match-pool
tomit4 il y a 2 ans
Parent
révision
73d9675bc8

+ 27
- 20
backend/lib/routes/membership/active.js Voir le fichier

71
                 profileId,
71
                 profileId,
72
                 membershipType,
72
                 membershipType,
73
             )
73
             )
74
+            if (!groupings.length) {
75
+                return {
76
+                    ok: true,
77
+                    handler: pluginConfig.handlerType,
78
+                    data: [],
79
+                }
80
+            }
74
             const groupingIds = groupings.map(grouping => grouping.grouping_id)
81
             const groupingIds = groupings.map(grouping => grouping.grouping_id)
75
-            const memberships = await membershipService.findMemberships(
76
-                groupingIds,
77
-            )
82
+            const memberships =
83
+                await membershipService.findMemberships(groupingIds)
78
             const profileIds = memberships
84
             const profileIds = memberships
79
                 .filter(membership => membership.profile_id != profileId)
85
                 .filter(membership => membership.profile_id != profileId)
80
                 .map(membership => membership.profile_id)
86
                 .map(membership => membership.profile_id)
81
 
87
 
82
             /** Assemble complete profiles to reference and pass */
88
             /** Assemble complete profiles to reference and pass */
83
-            const completedProfiles = await profileService.getProfilesFor(
84
-                profileIds,
85
-                'participant',
86
-            )
89
+            const completedProfiles = !profileIds.length
90
+                ? []
91
+                : await profileService.getProfilesFor(profileIds, 'participant')
87
 
92
 
88
             /**
93
             /**
89
              * Heavily process the result by storing just a profile_id
94
              * Heavily process the result by storing just a profile_id
91
              * !: This still assumes only ONE other profile
96
              * !: This still assumes only ONE other profile
92
              * TODO: should be refactored to many other profiles
97
              * TODO: should be refactored to many other profiles
93
              */
98
              */
94
-            const reformattedGroupings = groupings.map(grouping => {
95
-                const otherPid = grouping.profiles.find(
96
-                    p => p.profile_id != profileId,
97
-                ).profile_id
98
-                grouping.profile = completedProfiles.find(
99
-                    p => otherPid == p.profile_id,
100
-                )
101
-                grouping.is_paired = _activeGroupingIds(memberships).includes(
102
-                    grouping.grouping_id,
103
-                )
104
-                delete grouping.profiles
105
-                return grouping
106
-            })
99
+            const reformattedGroupings = groupings.length
100
+                ? groupings.map(grouping => {
101
+                      const otherPid = grouping.profiles.find(
102
+                          p => p.profile_id != profileId,
103
+                      ).profile_id
104
+                      grouping.profile = completedProfiles.find(
105
+                          p => otherPid == p.profile_id,
106
+                      )
107
+                      grouping.is_paired = _activeGroupingIds(
108
+                          memberships,
109
+                      ).includes(grouping.grouping_id)
110
+                      delete grouping.profiles
111
+                      return grouping
112
+                  })
113
+                : []
107
 
114
 
108
             /** Grabs revealTags */
115
             /** Grabs revealTags */
109
             const revealTags = await profileService.getTagsFor(
116
             const revealTags = await profileService.getTagsFor(

+ 1
- 0
backend/lib/schemas/profiles.js Voir le fichier

15
     tags: tagSchema.list,
15
     tags: tagSchema.list,
16
     media: Joi.any(),
16
     media: Joi.any(),
17
     blurb: Joi.any(),
17
     blurb: Joi.any(),
18
+    image: Joi.any(),
18
     user_type: Joi.any(),
19
     user_type: Joi.any(),
19
     user: userSchema.single,
20
     user: userSchema.single,
20
     profile_description: Joi.string().allow(null, ''),
21
     profile_description: Joi.string().allow(null, ''),

+ 20
- 15
backend/lib/services/profile/index.js Voir le fichier

364
     async getTagsFor(profileId, groupingId, category) {
364
     async getTagsFor(profileId, groupingId, category) {
365
         const { TagAssociation } = this.server.models()
365
         const { TagAssociation } = this.server.models()
366
         await this._setTagLookup()
366
         await this._setTagLookup()
367
-        let associations = groupingId
368
-            ? await TagAssociation.query()
369
-                  .where('grouping_id', groupingId)
370
-                  .andWhere('profile_id', profileId)
371
-            : await TagAssociation.query().andWhere('profile_id', profileId)
372
-        return associations
373
-            .map(assoc => ({
374
-                ...assoc,
375
-                tag: this.tagLookup[assoc.tag_id],
376
-            }))
377
-            .filter(tagWithAssoc => {
378
-                return category
379
-                    ? tagWithAssoc.tag.tag_category == category
380
-                    : true
381
-            })
367
+        let associations = []
368
+        if (!profileId.length || !groupingId.length) {
369
+            return associations
370
+        } else {
371
+            associations = groupingId
372
+                ? await TagAssociation.query()
373
+                      .where('grouping_id', groupingId)
374
+                      .andWhere('profile_id', profileId)
375
+                : await TagAssociation.query().andWhere('profile_id', profileId)
376
+            return associations
377
+                .map(assoc => ({
378
+                    ...assoc,
379
+                    tag: this.tagLookup[assoc.tag_id],
380
+                }))
381
+                .filter(tagWithAssoc => {
382
+                    return category
383
+                        ? tagWithAssoc.tag.tag_category == category
384
+                        : true
385
+                })
386
+        }
382
     }
387
     }
383
 
388
 
384
     /**
389
     /**

+ 4
- 4
frontend/src/components/ProfileCard.vue Voir le fichier

101
  * for both profileId and targetId
101
  * for both profileId and targetId
102
  */
102
  */
103
 const onPair = async () => {
103
 const onPair = async () => {
104
-    currentProfile._loading = true
104
+    currentProfile._loading.value = true
105
     const profileId = currentProfile.id.value
105
     const profileId = currentProfile.id.value
106
     const targetId = props.card.pid
106
     const targetId = props.card.pid
107
     await postMembershipByProfileId({
107
     await postMembershipByProfileId({
110
     })
110
     })
111
     await currentProfile.updateQueue(profileId, targetId, false)
111
     await currentProfile.updateQueue(profileId, targetId, false)
112
     await currentProfile.getGroupings()
112
     await currentProfile.getGroupings()
113
-    currentProfile._loading = false
113
+    currentProfile._loading.value = false
114
 
114
 
115
     let goToRoute = { name: 'HomeView' }
115
     let goToRoute = { name: 'HomeView' }
116
     router.push(goToRoute)
116
     router.push(goToRoute)
121
  * and forward back home
121
  * and forward back home
122
  */
122
  */
123
 const onPass = async () => {
123
 const onPass = async () => {
124
-    currentProfile._loading = true
124
+    currentProfile._loading.value = true
125
     await currentProfile.updateQueue(
125
     await currentProfile.updateQueue(
126
         currentProfile.id.value,
126
         currentProfile.id.value,
127
         props.card.pid,
127
         props.card.pid,
128
         true,
128
         true,
129
     )
129
     )
130
-    currentProfile._loading = false
130
+    currentProfile._loading.value = false
131
 
131
 
132
     let goToRoute = { name: 'HomeView' }
132
     let goToRoute = { name: 'HomeView' }
133
     router.push(goToRoute)
133
     router.push(goToRoute)

Chargement…
Annuler
Enregistrer