|
|
@@ -71,19 +71,24 @@ module.exports = {
|
|
71
|
71
|
profileId,
|
|
72
|
72
|
membershipType,
|
|
73
|
73
|
)
|
|
|
74
|
+ if (!groupings.length) {
|
|
|
75
|
+ return {
|
|
|
76
|
+ ok: true,
|
|
|
77
|
+ handler: pluginConfig.handlerType,
|
|
|
78
|
+ data: [],
|
|
|
79
|
+ }
|
|
|
80
|
+ }
|
|
74
|
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
|
84
|
const profileIds = memberships
|
|
79
|
85
|
.filter(membership => membership.profile_id != profileId)
|
|
80
|
86
|
.map(membership => membership.profile_id)
|
|
81
|
87
|
|
|
82
|
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
|
94
|
* Heavily process the result by storing just a profile_id
|
|
|
@@ -91,19 +96,21 @@ module.exports = {
|
|
91
|
96
|
* !: This still assumes only ONE other profile
|
|
92
|
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
|
115
|
/** Grabs revealTags */
|
|
109
|
116
|
const revealTags = await profileService.getTagsFor(
|