Skip to content

Commit

Permalink
Merge pull request #11 from fschrempf/feature/misc-improvements
Browse files Browse the repository at this point in the history
ctservice.js: Avoid global group membership endpoint alltogether
  • Loading branch information
fschrempf authored Oct 20, 2023
2 parents 94d6b4b + 1e6031e commit 61995a5
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/ctservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,17 @@ exports.getChurchToolsData = async (site) => {
});
}

if (allGroupsIds) {
log.info('Get Person IDs of Group Members from ChurchTools');
ctPersonIds = await this.getPersonsInGroups(site);
}

log.info('Get Groups from ChurchTools');
const ctGroups = await this.getGroups(allGroupsIds, site);
log.info('Get Group Memberships from ChurchTools');
const ctGroupIds = ctGroups.map((group) => group.id);
const ctGroupMembership = await this.getGroupMemberships(ctGroupIds, site);
log.info('Get Person Details from ChurchTools');
if (allGroupsIds != null) {
ctPersonIds = ctGroupMembership.map((member) => member.id);
ctPersonIds = Array.from(new Set(ctPersonIds));
}
const ctPersons = await this.getPersons(ctPersonIds, site);
log.info('Get Group Memberships from ChurchTools');
const groupIds = ctGroups.map((group) => group.id);
const ctGroupMembership = await this.getGroupMemberships(groupIds, site);

return {
groups: ctGroups,
Expand Down

0 comments on commit 61995a5

Please sign in to comment.