Skip to content

Commit

Permalink
Activity tab performance - switch from deprecatedGetActivitiesCount t…
Browse files Browse the repository at this point in the history
…o getActivitiesCount

ditto for getActivities.

This is a combination of 2 upstream PRs
civicrm#12557
and
civicrm#12559

Note - when trying to test use contact 72 - pretty sure at the moment the
new code is on staging & old on live

Bug: T199753
Bug: T191867

Change-Id: I1624b70eca431c018727618ebc7e8c35dc2121d4
  • Loading branch information
eileenmcnaughton committed Aug 2, 2018
1 parent a3bcb3f commit 34cb437
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
32 changes: 16 additions & 16 deletions CRM/Activity/BAO/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ public static function getActivities($params, $getCount = FALSE) {
continue;
}

$isBulkActivity = (!$bulkActivityTypeID || ($bulkActivityTypeID != $activity['activity_type_id']));
$isBulkActivity = (!$bulkActivityTypeID || ($bulkActivityTypeID === $activity['activity_type_id']));
foreach ($mappingParams as $apiKey => $expectedName) {
if (in_array($apiKey, array('assignee_contact_name', 'target_contact_name'))) {
$activities[$id][$expectedName] = CRM_Utils_Array::value($apiKey, $activity, array());
Expand Down Expand Up @@ -2862,10 +2862,10 @@ public static function getContactActivitySelector(&$params) {
}

// Get contact activities.
$activities = CRM_Activity_BAO_Activity::deprecatedGetActivities($params);
$activities = CRM_Activity_BAO_Activity::getActivities($params);

// Add total.
$params['total'] = CRM_Activity_BAO_Activity::deprecatedGetActivitiesCount($params);
$params['total'] = CRM_Activity_BAO_Activity::getActivitiesCount($params);

// Format params and add links.
$contactActivities = array();
Expand Down Expand Up @@ -2932,19 +2932,19 @@ public static function getContactActivitySelector(&$params) {
}
elseif (isset($values['target_contact_counter']) && $values['target_contact_counter']) {
$activity['target_contact_name'] = '';
foreach ($values['target_contact_name'] as $tcID => $tcName) {
$targetTypeImage = "";
$targetLink = CRM_Utils_System::href($tcName, 'civicrm/contact/view', "reset=1&cid={$tcID}");
if ($showContactOverlay) {
$targetTypeImage = CRM_Contact_BAO_Contact_Utils::getImage(
CRM_Contact_BAO_Contact::getContactType($tcID),
FALSE,
$tcID);
$activity['target_contact_name'] .= "<div>$targetTypeImage $targetLink";
}
else {
$activity['target_contact_name'] .= $targetLink;
}
$firstTargetName = reset($values['target_contact_name']);
$firstTargetContactID = key($values['target_contact_name']);

$targetLink = CRM_Utils_System::href($firstTargetName, 'civicrm/contact/view', "reset=1&cid={$firstTargetContactID}");
if ($showContactOverlay) {
$targetTypeImage = CRM_Contact_BAO_Contact_Utils::getImage(
CRM_Contact_BAO_Contact::getContactType($firstTargetContactID),
FALSE,
$firstTargetContactID);
$activity['target_contact_name'] .= "<div>$targetTypeImage $targetLink";
}
else {
$activity['target_contact_name'] .= $targetLink;
}

if ($extraCount = $values['target_contact_counter'] - 1) {
Expand Down
4 changes: 2 additions & 2 deletions CRM/Activity/Selector/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public function getTotalCount($action, $case = NULL) {
'rowCount' => 0,
'sort' => NULL,
);
return CRM_Activity_BAO_Activity::deprecatedGetActivitiesCount($params);
return CRM_Activity_BAO_Activity::getActivitiesCount($params);
}

/**
Expand Down Expand Up @@ -386,7 +386,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ca
'sort' => $sort,
);
$config = CRM_Core_Config::singleton();
$rows = CRM_Activity_BAO_Activity::deprecatedGetActivities($params);
$rows = CRM_Activity_BAO_Activity::getActivities($params);

if (empty($rows)) {
return $rows;
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/BAO/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -2727,7 +2727,7 @@ public static function getCountComponent($component, $contactId, $tableName = NU
'caseId' => NULL,
'context' => 'activity',
);
return CRM_Activity_BAO_Activity::deprecatedGetActivitiesCount($input);
return CRM_Activity_BAO_Activity::getActivitiesCount($input);

case 'mailing':
$params = array('contact_id' => $contactId);
Expand Down

0 comments on commit 34cb437

Please sign in to comment.