Commit 6e793248 authored by eileen's avatar eileen

Activity tab performance fix - switch to faster getActivities & getActivitiesCount

The getActivitiesCount & getActivities functions are faster & call permission hooks
but we weren't able to switch to them until we resolved some performance issues
(done) and resolved acl inconsistencies (resolved in 5.12) -we can do this now.

From a performance POV the difference is tab-crashes vs tab resolves quickly
on contacts with > 10k activities
parent 5a52625d
This diff is collapsed.
......@@ -401,9 +401,9 @@ class CRM_Activity_Page_AJAX {
'activity_type_id' => 'Integer',
'activity_type_exclude_id' => 'Integer',
'activity_status_id' => 'String',
'activity_date_relative' => 'String',
'activity_date_low' => 'String',
'activity_date_high' => 'String',
'activity_date_time_relative' => 'String',
'activity_date_time_low' => 'String',
'activity_date_time_high' => 'String',
);
$params = CRM_Core_Page_AJAX::defaultSortAndPagerParams();
......
......@@ -358,7 +358,7 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
'rowCount' => 0,
'sort' => NULL,
);
return CRM_Activity_BAO_Activity::deprecatedGetActivitiesCount($params);
return CRM_Activity_BAO_Activity::getActivitiesCount($params);
}
/**
......@@ -392,7 +392,7 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
'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;
......
......@@ -2734,7 +2734,7 @@ AND civicrm_openid.is_primary = 1";
'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);
......
......@@ -2170,4 +2170,41 @@ class CRM_Utils_Date {
return $month;
}
/**
* Convert a relative date format to an api field.
*
* @param array $params
* @param string $dateField
* @param bool $isDatePicker
* Non datepicker fields are deprecated. Exterminate Exterminate.
* (but for now handle them).
*/
public static function convertFormDateToApiFormat(&$params, $dateField, $isDatePicker = TRUE) {
if (!empty($params[$dateField . '_relative'])) {
$dates = CRM_Utils_Date::getFromTo($params[$dateField . '_relative'], NULL, NULL);
unset($params[$dateField . '_relative']);
}
if (!empty($params[$dateField . '_low'])) {
$dates[0] = $isDatePicker ? $params[$dateField . '_low'] : date('Y-m-d H:i:s', strtotime($params[$dateField . '_low']));
unset($params[$dateField . '_low']);
}
if (!empty($params[$dateField . '_high'])) {
$dates[1] = $isDatePicker ? $params[$dateField . '_high'] : date('Y-m-d 23:59:59', strtotime($params[$dateField . '_high']));
unset($params[$dateField . '_high']);
}
if (empty($dates)) {
return;
}
if (empty($dates[0])) {
$params[$dateField] = ['<=' => $dates[1]];
}
elseif (empty($dates[1])) {
$params[$dateField] = ['>=' => $dates[0]];
}
else {
$params[$dateField] = ['BETWEEN' => $dates];
}
}
}
......@@ -71,9 +71,9 @@
var status_id = $('.crm-activity-selector-' + context + ' select#status_id').val() || [];
d.activity_type_id = $('.crm-activity-selector-' + context + ' select#activity_type_filter_id').val(),
d.activity_type_exclude_id = $('.crm-activity-selector-' + context + ' select#activity_type_exclude_filter_id').val(),
d.activity_date_relative = $('select#activity_date_relative').val(),
d.activity_date_low = $('#activity_date_low').val(),
d.activity_date_high = $('#activity_date_high').val(),
d.activity_date_time_relative = $('select#activity_date_relative').val(),
d.activity_date_time_low = $('#activity_date_low').val(),
d.activity_date_time_high = $('#activity_date_high').val(),
d.activity_status_id = status_id.join(',')
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment