Browse Source

Merge pull request #85 from QuickMythril/member-count

Add member count to each group returned by GET /member/{address}
EPC-fixes
CalDescent 2 years ago committed by GitHub
parent
commit
3b3368f950
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/main/java/org/qortal/api/resource/GroupsResource.java

12
src/main/java/org/qortal/api/resource/GroupsResource.java

@ -158,7 +158,15 @@ public class GroupsResource {
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_ADDRESS); throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_ADDRESS);
try (final Repository repository = RepositoryManager.getRepository()) { try (final Repository repository = RepositoryManager.getRepository()) {
return repository.getGroupRepository().getGroupsWithMember(member); List<GroupData> allGroupData = repository.getGroupRepository().getGroupsWithMember(member);
allGroupData.forEach(groupData -> {
try {
groupData.memberCount = repository.getGroupRepository().countGroupMembers(groupData.getGroupId());
} catch (DataException e) {
// Exclude memberCount for this group
}
});
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);
} }
@ -931,4 +939,4 @@ public class GroupsResource {
} }
} }
} }

Loading…
Cancel
Save