Fix to the initial version of the correlation on the event index

- also removed an expensive lookup of sharing group permissions required for event views utilising the pagination from being run on actions that do not make use of it
pull/903/head
Iglocska 2016-01-31 00:32:17 +01:00
parent 12e32d4673
commit 3560b3bc06
1 changed files with 3 additions and 3 deletions

View File

@ -425,12 +425,12 @@ class Event extends AppModel {
$eventIds = Set::extract('/Event/id', $events);
$conditionsCorrelation = $this->__buildEventConditionsCorrelation($user, $eventIds, $sgids);
$correlations = $this->Correlation->find('all',array(
'fields' => array('Correlation.event_id', 'count(distinct(Correlation.1_event_id)) as count'),
'fields' => array('Correlation.1_event_id', 'count(distinct(Correlation.event_id)) as count'),
'conditions' => $conditionsCorrelation,
'recursive' => -1,
'group' => array('Correlation.event_id'),
'group' => array('Correlation.1_event_id'),
));
$correlations = Hash::combine($correlations, '{n}.Correlation.event_id', '{n}.0.count');
$correlations = Hash::combine($correlations, '{n}.Correlation.1_event_id', '{n}.0.count');
foreach ($events as &$event) $event['Event']['correlation_count'] = (isset($correlations[$event['Event']['id']])) ? $correlations[$event['Event']['id']] : 0;
}