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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Need help thinking through how to aggregate contact info...
Pages: [1]

Author Topic: Need help thinking through how to aggregate contact info...  (Read 534 times)

lee.gooding

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 1
    • Clear River Church
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • MySQL version: 5.7
  • PHP version: 5.3
Need help thinking through how to aggregate contact info...
June 09, 2014, 12:12:35 pm
Hopefully someone out here can help me think through this...

I am attempting to aggregate information for contacts. This includes information such as groups, tags, custom fields, relationships between, memberships, etc.

Maybe I am approaching this wrong, but it seems quite tedious to track down the information through the API. It seems like I'm getting IDs, then using those IDs to look up another set of information, which then gives me other IDs that I need to use for yet another API query. 

Is there any easier way to go about aggregating information using the API?

If not, wouldn't it just be much easier/faster to create an SQL view and then query that view? For example, I could do a query that returns rows for contacts that are in group X. That row would already have all the information that I might be interested in for that contact. I could simply pick and choose what I want to display from the row...

... OR would a combination be best? For example, for data that has multiple entries (such as activities and contributions) the API would be used in combination with a View?

I really appreciate any thoughts/insight into this.

Best,

Lee
« Last Edit: June 09, 2014, 12:28:52 pm by lee.gooding »

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Need help thinking through how to aggregate contact info...
June 09, 2014, 02:29:23 pm
It sounds like you already have your answer. A SQL view should work nicely for your use-case.
In general the CiviCRM API is not well-suited to generating complex reports that use a lot of joins. Not api3 anyway. There is some talk of doing this better in the next generation api, probably taking advantage of Doctrine's DQL, and we would welcome your involvement and input :)
Try asking your question on the new CiviCRM help site.

lee.gooding

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 1
    • Clear River Church
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • MySQL version: 5.7
  • PHP version: 5.3
Re: Need help thinking through how to aggregate contact info...
June 10, 2014, 06:56:14 am
That's good to know!

I appreciate the response. That gives me confidence to move forward from here.

Can you point me in the right direction for getting involved and giving input in this area? I'll help where I can!

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Need help thinking through how to aggregate contact info...
June 10, 2014, 09:21:41 am
Another direction might be to write your own custom api, that will we running the magic query with as many joins as you want and returns it.

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

lee.gooding

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 1
    • Clear River Church
  • CiviCRM version: 4.5
  • CMS version: Drupal 7
  • MySQL version: 5.7
  • PHP version: 5.3
Re: Need help thinking through how to aggregate contact info...
June 10, 2014, 10:49:12 am
Is there a particular advantage to this approach?

Quote from: xavier on June 10, 2014, 09:21:41 am
Another direction might be to write your own custom api, that will we running the magic query with as many joins as you want and returns it.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Need help thinking through how to aggregate contact info...
June 10, 2014, 10:53:01 am
It provides you the wrapper to retrieve it from php rest ajax or smarty+permission. that might or might not be useful in your case.
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Need help thinking through how to aggregate contact info...

This forum was archived on 2017-11-26.