-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
dev/core#942 fix failure to render names for some activities #14223
Conversation
(Standard links)
|
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 tested this locally and got an exception for contacts with activities without a target (see other comment for the likely reason).
Other than that, the target names don't seem to get rendered on the activity tab (both for single and bulk activities). Added/Assigned still works.
CRM/Activity/BAO/Activity.php
Outdated
// the moment as the bulk activity stuff needs unravelling & test coverage. | ||
foreach ($result as $id => $activity) { | ||
// Note that for the non-bulk ones we might get them in one fetch since we 'kinda know' it won't be an insane number | ||
if (!isset($activities[$id]['target_contact_count']) || !empty($activities[$id]['target_contact_count'])) { |
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 think this should be &&
- I'm getting "Expected one ActivityContact but found 0" for contacts with activities that have no target.
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.
@pfigel you are right - the outer function needs the target_contact_count set even when the inner one doesn't - There is a weird (read lack of) separation of concerns here.
I've switched to getting the counts for each activity with one simple group-by query, then using a with-acl api call to get the first name for each row with one or more targets.
This could lead to a mismatch - ie they see there are '4 more contacts' but they can't 'see' who they are. I think this is the right behaviour actually
7bf822d
to
0bd654c
Compare
Tested with the latest changes, results:
Backtrace
|
Thanks @pfigel I have fixed the bug on no activities that you (and the tests) picked up I think I'd rather leave the sort_name for a follow up. I want this to get a 5.13 drop sooner rather than later (my own local issues delayed me addressing this quicker) but the other can be a bit slower. Regarding the speed - it's good that the page you were testing was 50% faster. I would note that is something of a by-product since the main goal was to make it faster in cases the query was slow due to the unindexed joins - that was happening when there were lots of activities for a given contact - which is where we we seeing the tab performing extremely slowly |
SELECT activity_id, count(*) as target_contact_count | ||
FROM civicrm_activity_contact | ||
INNER JOIN civicrm_contact c ON contact_id = c.id AND c.is_deleted = 0 | ||
WHERE activity_id IN (' . implode(',', array_keys($result)) . ') |
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.
just thinking should this really be a param? not sure that you can actually inject anything but meh
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 tried but commaSeparatedInteger won't pass through in that way
- however it is definitely safe as they are the array keys from the api array
I have confirmed this fixes the last of Patrick's issues so adding merge on pass |
@eileenmcnaughton test fails look related |
da3f655
to
04d547a
Compare
Ok turns out the use of sort_name was tested so no letting it slip - re-fixed |
Overview ---------------------------------------- Set limit for activity_contact retrieval to 0, allowing to retrieve more than 25 activity contacts when rendering the first 25 activities on the activity contact tab Before ---------------------------------------- ![before](https://user-images.githubusercontent.com/336308/57439801-e42a0580-729a-11e9-80a1-45df93d0c5eb.jpg) After ---------------------------------------- ![after](https://user-images.githubusercontent.com/336308/57439960-39fead80-729b-11e9-9701-acd79ff73497.jpg) Technical Details ---------------------------------------- This moves the logic for retrieving the target contacts back into the getActivities function. We are stil not wanting to bypass the ACLs so still using the api but strictly limiting the number of contacts we retrieve (at the cost of extra queries, but cheap ones). Some tests added on the Bulk Mail activity. Comments ----------------------------------------
Test fail unrelated |
Overview
Set limit for activity_contact retrieval to 0, allowing to retrieve more than 25 activity contacts when rendering the first 25 activities on the activity contact tab
Before
After
Technical Details
This moves the logic for retrieving the target contacts back into the getActivities function. We are stil not wanting to bypass the ACLs so still using the
api but strictly limiting the number of contacts we retrieve (at the cost of extra queries, but cheap ones).
Some tests added on the Bulk Mail activity.
Comments
@pfigel I think some tests will fail now because I tweaked the test data to include a bulk mail type activity. However, let's see how it performs. I think we could reduce the cheap queries slightly but not doing a get-per-row on non-bulk but if there were an activity with many results that was of a different type it would still cause a slow down