Bladeren bron

:recycle: fixing up tag schema | fixing up pairing

tags/0.0.1^2
j 3 jaren geleden
bovenliggende
commit
4bfb93c941

+ 8
- 2
backend/lib/services/membership.js Bestand weergeven

122
         )
122
         )
123
         if (matchingGroupingIds.length) {
123
         if (matchingGroupingIds.length) {
124
             /** Grab all memberships associated with groupingIds */
124
             /** Grab all memberships associated with groupingIds */
125
-            let memberships = await findMemberships(matchingGroupingIds)
125
+            let memberships = await Membership.query().whereIn(
126
+                'grouping_id',
127
+                matchingGroupingIds,
128
+            )
126
 
129
 
127
             /** Set membership as active only if the user initiates it */
130
             /** Set membership as active only if the user initiates it */
128
             await this._patchMembership(memberships, profileId, {
131
             await this._patchMembership(memberships, profileId, {
130
             })
133
             })
131
 
134
 
132
             /** Make a new query to get updated information */
135
             /** Make a new query to get updated information */
133
-            memberships = await findMemberships(matchingGroupingIds)
136
+            memberships = await Membership.query().whereIn(
137
+                'grouping_id',
138
+                matchingGroupingIds,
139
+            )
134
             const groupings = await this._getGroupings(matchingGroupingIds, txn)
140
             const groupings = await this._getGroupings(matchingGroupingIds, txn)
135
             return { memberships, groupings }
141
             return { memberships, groupings }
136
         } else {
142
         } else {

+ 7
- 8
backend/lib/services/profile/index.js Bestand weergeven

27
         if (!Object.keys(this.tagLookup).length) {
27
         if (!Object.keys(this.tagLookup).length) {
28
             const { Tag } = this.server.models()
28
             const { Tag } = this.server.models()
29
             const allTagDescriptions = await Tag.query()
29
             const allTagDescriptions = await Tag.query()
30
-            allTagDescriptions.forEach(
31
-                desc =>
32
-                    (this.tagLookup[desc.tag_id] = {
33
-                        description: desc.tag_description,
34
-                        category: desc.tag_category,
35
-                    }),
36
-            )
30
+            allTagDescriptions.forEach(desc => {
31
+                if (desc.is_active) {
32
+                    this.tagLookup[desc.tag_id] = desc
33
+                }
34
+            })
37
         }
35
         }
38
     }
36
     }
39
     /**
37
     /**
66
             .withGraphFetched('user')
64
             .withGraphFetched('user')
67
 
65
 
68
         tagger.setProfileTags(matchingProfile, matchingProfile, this.tagLookup)
66
         tagger.setProfileTags(matchingProfile, matchingProfile, this.tagLookup)
69
-        return new profiler.CompleteProfile(matchingProfile)
67
+        const complete = new profiler.CompleteProfile(matchingProfile)
68
+        return complete
70
     }
69
     }
71
 
70
 
72
     async getCompleteProfilesFor(userId, type) {
71
     async getCompleteProfilesFor(userId, type) {

+ 9
- 2
backend/tests/membership.spec.js Bestand weergeven

21
  * Route parameters
21
  * Route parameters
22
  */
22
  */
23
 const params = {
23
 const params = {
24
-    profile_id: 1,
24
+    profile_id: 99,
25
 }
25
 }
26
 const mockReturn = {
26
 const mockReturn = {
27
     profile: {
27
     profile: {
28
         profile_id: 99,
28
         profile_id: 99,
29
-        user: {},
29
+        user_id: 99,
30
+        user: {
31
+            user_email: '',
32
+            user_name: 'bob',
33
+        },
30
         responses: [],
34
         responses: [],
31
         tags: [],
35
         tags: [],
32
     },
36
     },
143
         where: () => {
147
         where: () => {
144
             return mockReturn.memberships
148
             return mockReturn.memberships
145
         },
149
         },
150
+        whereIn: () => {
151
+            return mockReturn.memberships
152
+        },
146
     })
153
     })
147
     stub(server.models()['Profile'], 'query').returns({
154
     stub(server.models()['Profile'], 'query').returns({
148
         // Mocked for getProfile()
155
         // Mocked for getProfile()

+ 3
- 4
frontend/src/components/ProfileCard.vue Bestand weergeven

81
     updateQueueByProfileId(currentProfile.id.value, props.card.pid, false)
81
     updateQueueByProfileId(currentProfile.id.value, props.card.pid, false)
82
     currentProfile.getGroupings()
82
     currentProfile.getGroupings()
83
     console.warn('created grouping:', group)
83
     console.warn('created grouping:', group)
84
-    console.log('is grouping a match?:', group.membershipMatch.hasMatch)
85
 
84
 
86
     let goToRoute = { name: 'HomeView' }
85
     let goToRoute = { name: 'HomeView' }
87
-    if (group.membershipMatch.hasMatch) {
88
-        goToRoute = { name: 'PairsView' }
89
-    }
86
+    // if (group.membershipMatch.hasMatch) {
87
+    //     goToRoute = { name: 'PairsView' }
88
+    // }
90
     router.push(goToRoute)
89
     router.push(goToRoute)
91
 }
90
 }
92
 
91
 

+ 0
- 1
frontend/src/services/grouping.service.js Bestand weergeven

40
         grouping_type: groupingType,
40
         grouping_type: groupingType,
41
         grouping_name: `${utcDateInSeconds}_${profileId}_${targetId}`,
41
         grouping_name: `${utcDateInSeconds}_${profileId}_${targetId}`,
42
     }
42
     }
43
-    console.log('membership :', membership)
44
     const membershipMatch = await db.post(
43
     const membershipMatch = await db.post(
45
         `/membership/${profileId}/join`,
44
         `/membership/${profileId}/join`,
46
         membership,
45
         membership,

Laden…
Annuleren
Opslaan