Skip to content

Conversation

@cristianscheid
Copy link

@cristianscheid cristianscheid commented Jan 17, 2026

Summary

Fixes team population calculation to exclude nested teams from member counts.

Changes

  • When a team is added as member of another team, only users within the nested team are counted (team itself and duplicates are not counted)
  • When team members are added/removed, all parent circles (circles containing the updated circle) are also updated
  • When a team is deleted, all teams that contained that team are updated to reflect the removal
  • Added populationInherited field to Circle::jsonSerialize() alongside existing population for frontend usage in follow-up PR without breaking current frontend

Frontend follow-up needed

This PR addresses only the backend part of the issue. A follow-up PR in nextcloud/contacts is required to fix inconsistent count display:

  • Currently: uses population for member count on page load, but switches to member list length when clicking a team
  • Expected: consistently use the same count throughout the interface (populationInherited, added in this PR)

Checklist

CoreQueryBuilder::MEMBER,
$expr->andX(
$expr->eq(CoreQueryBuilder::MEMBERSHIPS . '.single_id', CoreQueryBuilder::MEMBER . '.single_id'),
$expr->eq(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$expr->eq(
$expr->neq(

If the method is supposed to exclude circles?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using neq in the JOIN matches each membership with all non-circle members sharing the same single_id, creating multiple rows when a user belongs to multiple circles. The eq + isNull approach avoids this by only joining with circle-type members. Since each single_id can only be a circle once (not multiple times), there's at most one match per membership. The isNull then filters to keep memberships that didn't match any circles, guaranteeing exactly one row per non-circle membership.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants