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) »
  • Issue with efficiency and API data returns.
Pages: [1]

Author Topic: Issue with efficiency and API data returns.  (Read 2260 times)

kengle3

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
Issue with efficiency and API data returns.
August 05, 2009, 11:03:38 pm
Right now I'm trying to write a drupal module which uses AJAX to show event participants that meet specified criteria.

Below is a small snippet of what I'm currently doing with my data:
Code: [Select]
$params = array(
                    'event_id' => 17,
                    'rowCount' => 500,
    );
$result =& civicrm_participant_search($params);
foreach($result as $results){
foreach($results as $individual){
$locparam=array('contact_id' => $individual['contact_id']);
$location = &civicrm_location_get($locparam)
//All other code utilizing each participants data here O(1)
}
}

Right now I'm dealing with a data set of roughly 400 participants for the test event. The code works, however ajax takes six or more seconds each update.

What I think the issue is, is that the API returns a multi-dimensional array. However I can't think of any way to traverse it that isn't O(n^2). Plus civicrm_location_get() probably has an order of at least O(n) making my function at least O(n^3). Does anyone have any suggestions of a more efficient way to pull all this data for my table?

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Issue with efficiency and API data returns.
August 06, 2009, 04:37:35 am
Just curious why are you not using View2 for listing participant records?

Kurund
Found this reply helpful? Support CiviCRM

kengle3

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
Re: Issue with efficiency and API data returns.
August 06, 2009, 04:52:47 am
I guess I'm not using it because I didn't know about Views2. I'll try figuring it out and see if that works better. Thanks =)

kengle3

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
Re: Issue with efficiency and API data returns.
August 06, 2009, 05:26:10 am
I just tried using Views2 a bit and it doesn't look like it does what I want because I want the table to change based upon what a user has entered in a text box. For example, I'll have a text box with "First Name:" and if it contains "A" it'd only list the names starting with a in the table. Also it doesn't seem like views2 allows onClick events for elements in the table.

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Issue with efficiency and API data returns.
August 06, 2009, 05:42:08 am
Since you want participant + their location details, I guess optimal solution will be to write your own single query according to your need.

Kurund
Found this reply helpful? Support CiviCRM

kengle3

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
Re: Issue with efficiency and API data returns.
August 06, 2009, 06:26:55 am
I am writing a Drupal module for CiviEvent check in.

The agent processing registrations has a several AJAX search fields that can be used to constrain the search for a participant (e.g. First Name, Last Name, City, State). As characters are typed into those fields, a table view is created with the list of participants who match the search criteria from which a participant can be selected or more characters can be typed to further constrain things.

In order to create a table with enough information to distinguish among, participants with the same name, I need to pull data for a participants location as well (differentiating between Kevin Smith of New Jersey and Kevin Smith of California).

I understand that I can directly code my search query, but that certainly makes this modules less maintainable (needing to be rewritten with every schema change). What I am trying to figure out is if there is some other set of API calls to accomplish what I need to do, or some other more efficient way of using the ones I am currently using.
« Last Edit: August 06, 2009, 07:02:48 am by kengle3 »

JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
Re: Issue with efficiency and API data returns.
August 09, 2009, 05:14:15 pm
You could also try using filters on your view.
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Issue with efficiency and API data returns.

This forum was archived on 2017-11-26.