CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • List of Civi Groups (both smart and not) - name and number of group members
Pages: [1] 2

Author Topic: List of Civi Groups (both smart and not) - name and number of group members  (Read 1122 times)

rminkov

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.1
  • PHP version: 5.3
List of Civi Groups (both smart and not) - name and number of group members
October 02, 2012, 07:48:57 am
We need to provide the management with a list of groups - name and number of contacts in the group.
Something like:

Corporate members - 1220
Non-corporate members - 2011
Journalists - 561
.......

I've been searching trough this forum, but did not find a solution for my problem and I am quite surprised that Civi does not have this simple feature.
I can manage simple things in php and mysql and I was looking at database level, but I am stuck with select_tables and where_tables fields.

At the API level I am stuck with the 25 results limitation.

At PHP level I am stuck with crm_get_groups - no such function.

Can you propose a solution?
« Last Edit: October 02, 2012, 07:50:46 am by rminkov »

Jason W

  • I post frequently
  • ***
  • Posts: 197
  • Karma: 12
  • jason@civitrainingtutorials.com
  • CiviCRM version: 4.2
  • CMS version: Drupal 7
  • MySQL version: 5.x
  • PHP version: 5.x.x
Re: List of Civi Groups (both smart and not) - name and number of group members
October 02, 2012, 09:25:21 am
Hello rminkov,

Try going to Search-->Find Contacts. Search for any contact with any tag, and select one of your groups from the available dropdown. When you click on search, the next screen will show you how many contacts are in the group. this number is right under the "Edit Search Criteria" section, on the left hand side.

This information can also be found from the Contacts-->Manage groups page, just click on contacts beside the group you need to view.

Cheers,
Jason
civiTrainingTutorials
"Helping You Help Others"

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: List of Civi Groups (both smart and not) - name and number of group members
October 02, 2012, 10:50:54 am
I agree that having the 'contact count' showing on the Manage Groups screen would be a great addition - do you have any skills to apply to this? If so probably worth jumping on IRC to get some guidance
Some question with a Smart Group
- do you show just a single number for 'all'
- or 2 numbers, one for 'smart' contacts and other for 'standard contacts'?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

rminkov

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.1
  • PHP version: 5.3
Re: List of Civi Groups (both smart and not) - name and number of group members
October 03, 2012, 03:44:03 am
Thanks Pete.
I am willing to try to fix this issue.
How can I contact you? My email is rado @ ceps.eu.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: List of Civi Groups (both smart and not) - name and number of group members
October 03, 2012, 04:55:25 am
good to hear - jump on to irc - http://irc.civicrm.org/ - and see if any of the core group or knowledge developers (not me) are around ;-)
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

rminkov

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.1
  • PHP version: 5.3
Re: List of Civi Groups (both smart and not) - name and number of group members
October 03, 2012, 07:52:18 am
I don't find anybody there.
Are there other ways?

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: List of Civi Groups (both smart and not) - name and number of group members
October 03, 2012, 07:54:32 am
there are a bunch of people on there right now - not sure why you ain't seeing anyone
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

rminkov

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.1
  • PHP version: 5.3
Re: List of Civi Groups (both smart and not) - name and number of group members
October 03, 2012, 09:02:48 am
Can somebody tell me how can I construct a smart group query from the where_clause, select tables and where tables fields?
It is not evident for me.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: List of Civi Groups (both smart and not) - name and number of group members
October 03, 2012, 09:11:02 am

You might want to use the API and/or the BAO functions, rather than using those columns directly

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

rminkov

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.1
  • PHP version: 5.3
Re: List of Civi Groups (both smart and not) - name and number of group members
October 04, 2012, 08:25:59 am
I already tried with API. The problem there is the limitation of 25 records, so basically getcount function returns 25 for all of the groups.

Can you tell me where to read about BAO functions? Some examples would be very helpful  :)

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: List of Civi Groups (both smart and not) - name and number of group members
October 04, 2012, 07:35:10 pm
the 25 limit can be overridden. see http://book.civicrm.org/developer/techniques/api/ (search for limit)

some info on baos here: http://book.civicrm.org/developer/introduction/the-codebase/
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

rminkov

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 4.4
  • CMS version: Drupal 6
  • MySQL version: 5.1
  • PHP version: 5.3
Re: List of Civi Groups (both smart and not) - name and number of group members
October 09, 2012, 02:00:02 am
Hi again,
The 25 limit can not be ovedrriden. It doesn't work on my installation, nor it works on demo server -
Code: [Select]
http://drupal.demo.civicrm.org/civicrm/ajax/doc/api#/civicrm/ajax/rest?json=1&sequential=1&debug=1&&entity=GroupContact&action=getcount&gid=2&limit=100 - this always returns result=25 (group with gid=2 has 73 members at the time i tried).

I was able to reconstruct the sql queries for the smart groups from where_clause and where_tables fields. If somebody is interested I will provide the code.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: List of Civi Groups (both smart and not) - name and number of group members
October 09, 2012, 02:35:26 am
On ajax, the syntax is option.limit. Could you update the wiki?

http://drupal.demo.civicrm.org/civicrm/ajax/doc/api#/civicrm/ajax/rest?json=1&sequential=1&debug=1&&entity=GroupContact&action=getcount&gid=2&option.limit=10000

returns 109.

I haven't checked, but if the api doesn't implement a specific getcount, the default version does do a normal get, count how many were fetched and trashes the result.

If you plan to do this query often, I would suggest to contribute a getcount for GroupContact (if not done already)
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: List of Civi Groups (both smart and not) - name and number of group members
October 09, 2012, 02:40:11 am
In my experience, we don't have any consistency on the label for limits on the API, e.g. http://issues.civicrm.org/jira/browse/CRM-9110

I'm too far away from the API to know what a good approach would be here (though I am close enough to know that some consistency would be good).

Xavier, as API queen, would you be able to preside over a judgement here?
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: List of Civi Groups (both smart and not) - name and number of group members
October 09, 2012, 05:36:06 am
Quote from: Michael McAndrew on October 09, 2012, 02:40:11 am
In my experience, we don't have any consistency on the label for limits on the API, e.g. http://issues.civicrm.org/jira/browse/CRM-9110

Xavier, as API queen, would you be able to preside over a judgement here?

We discussed it in apeldoorn, we got a few issues wrapped up

options => array (limit => 42)

is the preferred syntax. This syntax obviously doesn't work for ajax, so &option.limit=42 is the closest we could get.

As for the lack of consistency, agree, it sucks and we should fix it. However, as some api relies on bao that don't have a way of setting the limit, fixing becomes a "wee bit" more complex and we are more than welcoming any patch that would add the feature to the BAO (or move to the DAO)

Makes sense?

X+

-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • List of Civi Groups (both smart and not) - name and number of group members

This forum was archived on 2017-11-26.