-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow other base tables for api4-based smart groups #17003
Conversation
(Standard links)
|
if (CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) {$contactQuery['from']}") > 0) { | ||
CRM_Core_DAO::executeQuery("INSERT IGNORE INTO $tempTable (group_id, contact_id) {$contactQuery['select']} {$contactQuery['from']}"); | ||
} | ||
CRM_Core_DAO::executeQuery("INSERT IGNORE INTO $tempTable (group_id, contact_id) {$contactQuery['select']} {$contactQuery['from']}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the SELECT COUNT
for 2 reasons:
- It was causing the API query to crash because swapping the
SELECT
clause forSELECT COUNT(*)
loses our field alias which theHAVING
clause relies on. - I'm unclear about the effectiveness of this optimization. It looks to me like it's causing the query to run twice, so I'm not sure how that's more efficient. Looks like fairly recent work of @seamuslee001 though so I'll let him chime in here and tell me why I'm wrong :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@colemanw Can you pull this bit out into a separate PR? It was part of the refactoring to improve performance / reduce database deadlocks work so changing it carries quite a high risk (ie. needs testing thoroughly). That said, the refactoring was an improvement rather than an end-point so I'm happy to see further improvements like this :-)
For example, in theory we should not have needed the INSERT IGNORE
- INSERT
should have been ok, but in practise it wasn't.. (probably because further improvement is required to reduce concurrency).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2b83dfa
to
d07cceb
Compare
retest this please |
9f74998
to
6e4e89d
Compare
The "additional cleanup" commit was causing tests to crash so I'm splitting that off to a separate PR to investigate. This PR should be merge-ready now. |
retest this please |
6e4e89d
to
4810225
Compare
Allow other base tables for api4-based smart groups
Overview
Expands support for API based smart groups, allowing any api entity as the starting point, not just
Contact
.Before
Could only create a smart group from
Contact
API entity.After
Any API entity allowed. The API explorer supports this, and also now provides some rudimentary validation to ensure contact_id is selected by the API query.
Technical Details
The
GroupContactCache
was tacking on an additionalWHERE
clause to exclude removed group contacts. I converted it to aHAVING
clause for API queries because that's more flexible.