chg: [internal] Faster loading sightings if the same attribute is requested

pull/6045/head
Jakub Onderka 2020-06-22 17:35:04 +02:00
parent 4693929a5d
commit ea5a819064
1 changed files with 5 additions and 2 deletions

View File

@ -216,7 +216,8 @@ class Sighting extends AppModel
}
$conditions = array('Sighting.event_id' => $event['Event']['id']);
if ($attribute_id) {
$conditions[] = array('Sighting.attribute_id' => $attribute_id);
$attribute = $this->Attribute->fetchAttribute($attribute_id);
$conditions['Sighting.attribute_id'] = $attribute_id;
}
if (!$ownEvent && (!Configure::read('Plugin.Sightings_policy') || Configure::read('Plugin.Sightings_policy') == 0)) {
$conditions['Sighting.org_id'] = $user['org_id'];
@ -263,7 +264,9 @@ class Sighting extends AppModel
$sightings[$k]['Sighting']['Organisation'] = $sightings[$k]['Organisation'];
}
// zeroq: add attribute UUID to sighting to make synchronization easier
$attribute = $this->Attribute->fetchAttribute($sighting['Sighting']['attribute_id']);
if (!isset($attribute)) {
$attribute = $this->Attribute->fetchAttribute($sighting['Sighting']['attribute_id']);
}
$sightings[$k]['Sighting']['attribute_uuid'] = $attribute['Attribute']['uuid'];
$sightings[$k] = $sightings[$k]['Sighting'] ;