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) »
  • events api improvement
Pages: [1]

Author Topic: events api improvement  (Read 831 times)

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
events api improvement
January 22, 2011, 09:04:10 pm
I recommend an improvement to the event_search api to include a new special parameter allowing the retrieval of only current and future events (currently not possible)

patch here: http://issues.civicrm.org/jira/browse/CRM-7425
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: events api improvement
January 22, 2011, 11:04:50 pm
Brian,

I don't think this should be a return parameter - it looks from your code that it is a search parameter - i.e the acceptable param should be

$params['is_current'] = 1;

There are a handful of objects where being able to search on 'is_current' and having 'is_current' returned (probably as standard) would be really useful inc

Event
Participant
Membership
Pledge?

I think it would be worth implementing this for event in v3 (and others if people do them) but we should possibly try to push the functionality down to the BAO function?
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

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: events api improvement
January 22, 2011, 11:14:53 pm
is_current is generally passed as a parameter when it's also a column in the table.
in this case, there's no field in the table -- we have to construct the logic for what defines current/future

so i followed the pattern established for the offset and rowCount "special" parameters that are already available in this function.
as for passing down to the BAO -- this API is constructed from a DAO query, as I recall (don't have it in front of me). wouldn't it be easier to just maintain the additional clause there, along with everything else?
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

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: events api improvement
January 23, 2011, 06:49:55 am

We might want to have a protocol for parameters which are not DB columns. So something like isCurrent might make a bit easier to differentiate between DB columns and "meta" values

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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: events api improvement
January 23, 2011, 07:29:36 am
I'm thorn on that one.

On one hand, I like the idea of matching as closely as possible the underlying DB, on the other, what happen in 6 month time if we change the structure and implement is_current as a field instead of calculated value ?

I'd argue as I user of the api, I don't care how that's implemented, and the is_current is coherent and does what it says on the box.

Agree with Eileen, shouldn't be a return param, but a "regular" param.

IMO, same goes for return.max_params. Should be rowCount, as in civicrm_contact_get.

X+

P.S. no matter what it should be rowCount everywhere or return.max_results everywhere or whatever, but the same.
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: events api improvement
January 23, 2011, 07:55:19 am
i'd vote for something along the lines of what lobo is suggesting -- treating these params separately but consistently.

"normal" params = value lookups (data)
return.xxx = what fields should be returned
filter.xxx = special use restrictions or behaviors -- which may or may not impact the where clause

support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: events api improvement
January 23, 2011, 11:06:28 am
The special columns that are currently standard are

'sort'
'rowCount'
'offset'
'smartGroupCache
'return.x'

I agree it would be good to prepend something to the 'special' fields - not sure if we could come up with something that applies to 'is_current' and also to the top 4 (note this would be implemented in v3 (not a change in v2 - Brian - v3 repo is http://svn.civicrm.org/civicrm/branches/trunk.api). If you want to backport the v3 version to code against it (so it will stay there) you might want to change the require once in it to the v2/Utils file or your local to ensure no conflicts for now.

Also, once we agree implementation & description you might want to futureproof your implementation by adding it to one of the event api tests)
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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: events api improvement
January 26, 2011, 03:10:58 am
Brian - I think we've voted for 'isCurrent' - strangely enough as suggested by Lobo

But  if you want it to be safe forever more I suggest you edit the unit tests as well
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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: events api improvement
January 26, 2011, 03:36:46 am
As a side node, why would everyone find nicer

Code: [Select]
array (
return_bla => true,
return_bli => true,
whatever = > 'xy'
);

than

Code: [Select]
array (
return => array ('bli','bla'), 
whatever = > 'xy'
);

or (mostly as a get param on the rest, already implemented)
Code: [Select]
array (
return => 'bli,bla', 
whatever = > 'xy'
);

?


Quote from: lcdweb on January 23, 2011, 07:55:19 am
"normal" params = value lookups (data)
return.xxx = what fields should be returned
filter.xxx = special use restrictions or behaviors -- which may or may not impact the where clause
-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) »
  • events api improvement

This forum was archived on 2017-11-26.