Api4: add calculated field contact_count
to Group
#26313
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This adds a calculated field 'contact_count
to the
Group.get()` API. This provides the current count of 'added' group members and smart group members. Note this does not rebuild the group cache so smart group counts may be out of date or zero.Before
Cannot get count of smart group contacts.
After
Count of smart group contacts available as
contact_count
fieldTechnical Details
Contacts manually added to a smart group are included in the
civicrm_group_contact_cache
table. So if the count from that table is non-zero, the group is smart and the count is the total number of contacts. If the count is zero, either the group is not smart, or the cache table has not been rebuilt. Either way, report the number of contacts incivicrm_group_contact
Comments
Anything else you would like the reviewer to note