forked from Qortal/qortal
Add member count to each group returned by GET /groups (expanded on code written by QuickMythril)
This commit is contained in:
parent
ad31d8014d
commit
fee603e500
@ -99,7 +99,13 @@ public class GroupsResource {
|
|||||||
) @QueryParam("reverse") Boolean reverse) {
|
) @QueryParam("reverse") Boolean reverse) {
|
||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
List<GroupData> allGroupData = repository.getGroupRepository().getAllGroups(limit, offset, reverse);
|
List<GroupData> allGroupData = repository.getGroupRepository().getAllGroups(limit, offset, reverse);
|
||||||
// allGroupData.forEach(GroupData -> GroupData.memberCount = repository.getGroupRepository().countGroupMembers(GroupData.groupId));
|
allGroupData.forEach(groupData -> {
|
||||||
|
try {
|
||||||
|
groupData.memberCount = repository.getGroupRepository().countGroupMembers(groupData.getGroupId());
|
||||||
|
} catch (DataException e) {
|
||||||
|
// Exclude memberCount for this group
|
||||||
|
}
|
||||||
|
});
|
||||||
return allGroupData;
|
return allGroupData;
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.REPOSITORY_ISSUE, e);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.REPOSITORY_ISSUE, e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user