fix: [internal] Reduce number of fetched attributes

pull/8356/head
Jakub Onderka 2022-05-12 09:34:28 +02:00
parent ab728e102a
commit 9735b2a5fc
2 changed files with 8 additions and 6 deletions

View File

@ -1618,7 +1618,7 @@ class Attribute extends AppModel
'Attribute.sharing_group_id',
],
'order' => 'Attribute.id',
'limit' => 10000,
'limit' => 5000,
'callbacks' => false, // memory leak fix
];
do {
@ -1629,7 +1629,7 @@ class Attribute extends AppModel
}
$fetchedAttributes = count($attributes);
$attributeCount += $fetchedAttributes;
if ($fetchedAttributes === 10000) { // maximum number of attributes fetched, continue in next loop
if ($fetchedAttributes === 5000) { // maximum number of attributes fetched, continue in next loop
$query['conditions']['Attribute.id >'] = $attribute['Attribute']['id'];
} else {
break;

View File

@ -248,6 +248,9 @@ class Correlation extends AppModel
$this->Job->saveProgress($jobId, __('Correlating Attributes based on value. %s attributes correlated out of %s.', $k, $count), floor(100 * $k / $count));
}
}
if (empty($correlations)) {
return true;
}
return $this->__saveCorrelations($correlations);
}
@ -257,9 +260,6 @@ class Correlation extends AppModel
*/
private function __saveCorrelations($correlations)
{
if (empty($correlations)) {
return true;
}
$fields = [
'value', '1_event_id', '1_attribute_id', 'event_id', 'attribute_id', 'org_id',
'distribution', 'a_distribution', 'sharing_group_id', 'a_sharing_group_id',
@ -421,7 +421,9 @@ class Correlation extends AppModel
);
}
}
unset($correlatingAttributes);
if (empty($correlations)) {
return true;
}
return $this->__saveCorrelations($correlations);
}