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 CiviEvent (Moderator: Yashodha Chaku) »
  • Detecting Event Full via API
Pages: [1]

Author Topic: Detecting Event Full via API  (Read 1131 times)

scjohn

  • I’m new here
  • *
  • Posts: 5
  • Karma: 0
  • CiviCRM version: civicrm-3.2.3-drupal
  • CMS version: civicrm-3.2.3-drupal
  • MySQL version: mysql Ver 14.14 Distrib 5.1.50,
  • PHP version: PHP 5.3.3
Detecting Event Full via API
February 04, 2011, 05:09:01 am
I am using the rest API to create event participants but I don't see how I can easily detect the number of users already registered so I don't overflow the event.

Any suggestions?

civicrm-3.2.3

John

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Detecting Event Full via API
February 04, 2011, 06:37:26 am
Hi,

Would use the participant_get api.

If you are using the API, please consider joining and helping us on the migration to v3, that will make your migration easier ;)

(no, we aren't going to switch off the v2 and maintain the 2 in parallel for a while, but v3 is definitely the future)

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

scjohn

  • I’m new here
  • *
  • Posts: 5
  • Karma: 0
  • CiviCRM version: civicrm-3.2.3-drupal
  • CMS version: civicrm-3.2.3-drupal
  • MySQL version: mysql Ver 14.14 Distrib 5.1.50,
  • PHP version: PHP 5.3.3
Re: Detecting Event Full via API
February 04, 2011, 06:46:40 am
So if I understand the API docs I can use the participant_search to get a list of all participants for an event.  Does an option exist to just receive the current count(s) for an event?

I don't have much control on the version being used,  but I expect we will upgrade shortly.

Thanks.
John

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Detecting Event Full via API
February 04, 2011, 08:41:38 am
Not from the top of my head,  but check api/v2/Participant.php

It might be worthwhile having a new API civicrm_event_getAvailable added to Event.php in the API ?
X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

scjohn

  • I’m new here
  • *
  • Posts: 5
  • Karma: 0
  • CiviCRM version: civicrm-3.2.3-drupal
  • CMS version: civicrm-3.2.3-drupal
  • MySQL version: mysql Ver 14.14 Distrib 5.1.50,
  • PHP version: PHP 5.3.3
Re: Detecting Event Full via API
February 04, 2011, 11:09:18 am
I am pretty new to Civi,  but yea it seems being able to test the availability of an event slot would be nice.

I will be happy to submit a patch if you can help me with the specifications.  I'll try to support v2 and v3.

event_get_counts ( id )

  'counted', 'not_counted', 'registered', etc.  What values should be in the return?


john

scjohn

  • I’m new here
  • *
  • Posts: 5
  • Karma: 0
  • CiviCRM version: civicrm-3.2.3-drupal
  • CMS version: civicrm-3.2.3-drupal
  • MySQL version: mysql Ver 14.14 Distrib 5.1.50,
  • PHP version: PHP 5.3.3
Re: Detecting Event Full via API
February 04, 2011, 12:40:51 pm
This is what I have come up with so far: http://pastebin.com/jBBD0Niw

It is a start,  suggestions?

John

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Detecting Event Full via API
February 04, 2011, 02:42:26 pm
Hi,

That's taking shape!

I'd prefer civicrm_event_getcount () as the name.

or a new key count=1 on the civicrm_event_get ? A-team to the rescue, what do you think ?

Otherwise, on the v3, some conventions are a bit different: you have a try {} catch around all the code, and use civicrm_create_success.

http://wiki.civicrm.org/confluence/display/CRMDOC33/How+to+migrate+or+write+an+api

for the details.

Thanks for your help, ping us on the forum or the IRC if something isn't clear, I'd love having your feed-back on that.

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

scjohn

  • I’m new here
  • *
  • Posts: 5
  • Karma: 0
  • CiviCRM version: civicrm-3.2.3-drupal
  • CMS version: civicrm-3.2.3-drupal
  • MySQL version: mysql Ver 14.14 Distrib 5.1.50,
  • PHP version: PHP 5.3.3
Re: Detecting Event Full via API
February 05, 2011, 07:18:55 am
No idea why I changed the name,  I noticed that after I made the post.  I was originally trying to return a bit more information, then I saw the RM_Event_BAO_Participant::eventFull and switched to using that.

eventFull returns the number of available slots,  OR the 'event full' error message from the event.  As I have this right not I simply return exactly what eventFull gives me.  Would it be preferred to return a 0 and then an additional key that contains the 'event full' message?

Would you rather me update the existing get_event function,  or create a new one?  I can live with either implementation.

I'll see if I can get a more cleaned up solution sometime this weekend,  what is the preferred method for submitting patches?

John

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
How to contribute
February 05, 2011, 07:43:22 am
Hi,

have you already installed api.trunk branch from the svn ?

They are quite a new helper functions to handle the check of mandatory fields, and in general that's the place to add the v3 apis.

I'd suggest to write a civicrm_event_get_count in api/v3/Events.php and a test in tests/phpunit/api/v3/EventTest.php

as for the format of the return I'd suggest (if they are all easily available):
values {
'participants'=20, 'notCountedParticipants'=3, 'notCountedDueToRole'=6, 'notCountedDueToStatus'=9, 'availableSeats' = 6, 'totalSeats' = 300
}

availableSeats is totalSeats - participants and will be 0 when your event is full.

Make sense ?

As for the format to contribute, please create an issue, attach the svn diff and assign the issue to me.

I might be a bit on the IRC this week-end, but mostly you're likely to catch me on this thread.

Many thanks for your contrib.
X+

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

narragansett

  • I post occasionally
  • **
  • Posts: 47
  • Karma: 2
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6.20
  • MySQL version: 5.1.41
  • PHP version: 5.3.2-1
Re: Detecting Event Full via API
February 05, 2011, 05:53:25 pm
It looks like what you're working on could very well solve the problem I have as well (see the thread below).  I'm new to this kind of stuff, so please pardon me if the question is inappropriate, but is this code something that might be made available to someone like myself, or would you keep it for private use?

I'd guess it will be made public based on your question about the preferred method for submitting patches, but again, I'm new to all this so I don't want to make any assumptions.  If it will be made public, I'd like to find out when it is done so that I can see if it will in fact solve my issue.

Thanks.

http://forum.civicrm.org/index.php/topic,18477.0.html

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Detecting Event Full via API

This forum was archived on 2017-11-26.