chg: [sync] Examine less events for sightings pulling

pull/7713/head
Jakub Onderka 2021-09-01 11:43:12 +02:00
parent 407008af16
commit 4973c7480d
2 changed files with 9 additions and 2 deletions

View File

@ -55,7 +55,7 @@ class EventBlocklist extends AppModel
public function removeBlockedEvents(array &$eventArray)
{
// When event array contains a lot events, it is more efficient to fetch all blocked events
$conditions = count($eventArray) > 10000 ? [] : ['EventBlocklist.event_uuid' => array_column($eventArray, 'uuid')];
$conditions = (count($eventArray) > 10000) ? [] : ['EventBlocklist.event_uuid' => array_column($eventArray, 'uuid')];
$blocklistHits = $this->find('column', [
'conditions' => $conditions,
'fields' => ['EventBlocklist.event_uuid'],

View File

@ -1127,10 +1127,17 @@ class Sighting extends AppModel
return 0;
}
// Remove events from list that do not have published sightings.
foreach ($remoteEvents as $k => $remoteEvent) {
if ($remoteEvent['sighting_timestamp'] == 0) {
unset($remoteEvents[$k]);
}
}
// Downloads sightings just from events that exists locally and remote sighting_timestamp is newer than local.
$localEvents = $this->Event->find('list', [
'fields' => ['Event.uuid', 'Event.sighting_timestamp'],
'conditions' => count($remoteEvents) > 10000 ? ['Event.uuid' => array_column($remoteEvents, 'uuid')] : [],
'conditions' => (count($remoteEvents) > 10000) ? [] : ['Event.uuid' => array_column($remoteEvents, 'uuid')],
]);
$eventUuids = [];