소스 검색

:recycle: adjusted grouping return for matches

tags/0.0.1
J 4 년 전
부모
커밋
7105a69e8f
1개의 변경된 파일10개의 추가작업 그리고 3개의 파일을 삭제
  1. 10
    3
      backend/lib/services/membership.js

+ 10
- 3
backend/lib/services/membership.js 파일 보기

@@ -10,17 +10,24 @@ module.exports = class MembershipService extends Schmervice.Service {
10 10
      * @param {number} profileId
11 11
      * @returns {Array} List of all grouping_ids for user
12 12
      */
13
-    async _getGroupingIdsForProfileId(profileId, type) {
13
+    async _getGroupingIdsForProfileId(profileId, type, active) {
14 14
         const { Membership } = this.server.models()
15 15
 
16 16
         /** Grab every Membership associated with this id */
17 17
         let allMemberships
18 18
 
19
-        if(type) {
19
+        if(type && active == 'any') {
20
+            allMemberships = await Membership.query()
21
+                .where({ profile_id: profileId })
22
+                .where({ membership_type: type })
23
+        } else if (type) {
20 24
             allMemberships = await Membership.query()
21 25
                 .where({ profile_id: profileId })
22 26
                 .where({ membership_type: type })
23 27
                 .where({ is_active: true })
28
+        } else if(active == 'any') {
29
+            allMemberships = await Membership.query()
30
+                .where({ profile_id: profileId })
24 31
         } else {
25 32
             allMemberships = await Membership.query()
26 33
                 .where({ profile_id: profileId })
@@ -74,7 +81,7 @@ module.exports = class MembershipService extends Schmervice.Service {
74 81
     async findGroupingsByProfileId(profileId, type) {
75 82
         const { Grouping } = this.server.models()
76 83
 
77
-        const dedupedGroupings = await this._getGroupingIdsForProfileId(profileId, type)
84
+        const dedupedGroupings = await this._getGroupingIdsForProfileId(profileId, type, 'any')
78 85
 
79 86
         /** Grab just the Groupings this id has a Membership for */
80 87
         return await Grouping.query()

Loading…
취소
저장