Просмотр исходного кода

:recycle: returning only groups with active memberships

tags/0.0.1
J 4 лет назад
Родитель
Сommit
92b0cec38f
3 измененных файлов: 7 добавлений и 8 удалений
  1. 1
    1
      backend/db/mock.js
  2. 2
    2
      backend/lib/routes/membership/active.js
  3. 4
    5
      backend/lib/services/membership.js

+ 1
- 1
backend/db/mock.js Просмотреть файл

723
             grouping_id: 5,
723
             grouping_id: 5,
724
             membership_type: 'participant',
724
             membership_type: 'participant',
725
             can_edit: false,
725
             can_edit: false,
726
-            is_active: true,
726
+            is_active: false,
727
         },
727
         },
728
     ],
728
     ],
729
     groupings: [
729
     groupings: [

+ 2
- 2
backend/lib/routes/membership/active.js Просмотреть файл

15
     // headers: true,
15
     // headers: true,
16
 
16
 
17
     /** Validate the route params (/active/{thing}) */
17
     /** Validate the route params (/active/{thing}) */
18
-    params: Joi.object({ user_id: Joi.number() }),
18
+    params: Joi.object({ profile_id: Joi.number() }),
19
 
19
 
20
     /** Validate the route query (/active/{thing}?limit=10&offset=10) */
20
     /** Validate the route query (/active/{thing}?limit=10&offset=10) */
21
     // query: true,
21
     // query: true,
34
 
34
 
35
 module.exports = {
35
 module.exports = {
36
     method: 'GET',
36
     method: 'GET',
37
-    path: '/active/{profile_id}',
37
+    path: '/{profile_id}',
38
     options: {
38
     options: {
39
         ...pluginConfig.docs,
39
         ...pluginConfig.docs,
40
         tags: ['api'],
40
         tags: ['api'],

+ 4
- 5
backend/lib/services/membership.js Просмотреть файл

14
         const { Membership } = this.server.models()
14
         const { Membership } = this.server.models()
15
 
15
 
16
         /** Grab every Membership associated with this id */
16
         /** Grab every Membership associated with this id */
17
-        const allMemberships = await Membership.query().where(
18
-            'profile_id',
19
-            profileId,
20
-        )
21
-
17
+        const allMemberships = await Membership.query()
18
+            .where({ profile_id: profileId })
19
+            .where({ is_active: true })
20
+        
22
         /** Copy a list of the just the Groupings */
21
         /** Copy a list of the just the Groupings */
23
         const groupingIdsToGrab = allMemberships.map(
22
         const groupingIdsToGrab = allMemberships.map(
24
             membership => membership.grouping_id,
23
             membership => membership.grouping_id,

Загрузка…
Отмена
Сохранить