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 (Moderator: Donald Lobo) »
  • Retrieving Report Data via api
Pages: [1]

Author Topic: Retrieving Report Data via api  (Read 738 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Retrieving Report Data via api
December 04, 2013, 09:12:31 pm
We've had some email discussions about this & I thought I would push it onto the forum. Basically we are looking at how to retrieve data from reports in order to display in charts. This breaks the linkage between the report & the chart as we look at alternatives to OpenFlashChart. Xavier has done a lot of work on charting with his civisualize & current expectation is that we will use that to display dashlet reports.

So, the step I am currently focussed on is retrieving report data via the api.

I have had some initial success with this patch https://github.com/eileenmcnaughton/civicrm-core/pull/2

 civicrm_api3('report_template', 'getrows', array('json => 1, 'report_id' => 'contribute/recovery', ' instance_id' =>36);


returns

{
 "is_error":0,
 "version":3,
 "count":2,
 "values":[{
    "from_date":"2011-01-01",
    "to_date":"2011-12-31",
   "recovered":"789",
   "prior":"670"
  },{
  "from_date":"2012-01-01",
  "to_date":"2012-12-31",
  "recovered":"888",
  "prior":"444"}]}

This report is a summary report which means the reported rows are already aggregated. The desire is to transform this data into the chart described here
http://wiki.civicrm.org/confluence/display/CRM/CiviEngage+Enhancements+for+fund-raising#CiviEngageEnhancementsforfund-raising-2.LapsedandRecoveredDonorsChart.

In this example the report is showing what happened to people this year who 'lapsed' last year. Ie. The paid in year 0, didn't pay in year 1 & now we want to know what portion of them came back in year 3 ('recovered') & what portion did not ('prior').  The confusing-ness of the word prior highlights that the api should possibly also return column titles & extra text to be rendered.

Note that the changes to core are only additional functions, setter & getter methods & a couple of conditionals. I would think that this is a candidate for inclusion in 4.4 (but not the release due out this week). I have tested with & without the report instance id as a param  & that works nicely. I have not looked at passing in fields / filters etc yet.

Feedback welcome - comments related to the commits - please add on github. Please discuss here as to how the inputs & outputs of the api work / could be converted to a {crmReport} tag & a graph. Please start your own thread if you discuss the actual report (ie. the specs of it) so this doesn't get hijacked by discussion about the PTP reports specs. (yes, we know some people prefer x graph over y graph)

« Last Edit: December 04, 2013, 09:19:25 pm by Eileen »
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Retrieving Report Data via api
December 04, 2013, 11:30:53 pm
Cool stuff!
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Retrieving Report Data via api
December 05, 2013, 01:31:36 am
I support people that prefer x graph over y graph!
I even support people that prefer x+ graph over y+ graph!

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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Retrieving Report Data via api
December 05, 2013, 05:41:45 pm
As Lobo said the api could go in 4.4.4 I also did some tests - they highlighted a few existing bugs & a few reports that won't currently work with the api - but I think that's good progress. I also added a getstatistics api (which gets the values from the bottom of the page)
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Retrieving Report Data via api

This forum was archived on 2017-11-26.