X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FUpdateContacts.php;h=2beb890918538373c87a2e647ba567638da8cba9;hb=60532ee7e4152af9997e0d7b69c7b35262d5528d;hp=86959c88bbbf56cf0e7cd2e6cb1eea4002926fa9;hpb=ef7ebec4b72ff1d7d8bc0eff3ad0f096b02c9400;p=friendica.git diff --git a/src/Worker/UpdateContacts.php b/src/Worker/UpdateContacts.php index 86959c88bb..2beb890918 100644 --- a/src/Worker/UpdateContacts.php +++ b/src/Worker/UpdateContacts.php @@ -1,6 +1,6 @@ count($ids)]); - $conditions = ["`id` IN (SELECT `author-id` FROM `post-user`)", "`id` IN (SELECT `owner-id` FROM `post-user`)", - "`id` IN (SELECT `causer-id` FROM `post-user`)", "`id` IN (SELECT `cid` FROM `post-tag`)", - "`id` IN (SELECT `cid` FROM `user-contact`)"]; + $conditions = ["`id` IN (SELECT `author-id` FROM `post` WHERE `author-id` = `contact`.`id`)", + "`id` IN (SELECT `owner-id` FROM `post` WHERE `owner-id` = `contact`.`id`)", + "`id` IN (SELECT `causer-id` FROM `post` WHERE `causer-id` = `contact`.`id`)", + "`id` IN (SELECT `cid` FROM `post-tag` WHERE `cid` = `contact`.`id`)", + "`id` IN (SELECT `cid` FROM `user-contact` WHERE `cid` = `contact`.`id`)"]; foreach ($conditions as $contact_condition) { $condition = DBA::mergeConditions($base_condition, - [$contact_condition . " AND (`last-update` < ? OR (NOT `archive` AND `last-update` < ?))", + [$contact_condition . " AND (`last-update` < ? OR (NOT `failed` AND `last-update` < ?))", DateTimeFormat::utc('now - 1 month'), DateTimeFormat::utc('now - 1 week')]); - $ids = self::getContactsToUpdate($condition, $ids, $limit); + $ids = self::getContactsToUpdate($condition, $limit, $ids); Logger::info('Fetched interacting federated contacts', ['count' => count($ids), 'condition' => $contact_condition]); } @@ -75,10 +77,10 @@ class UpdateContacts // Add every contact (mostly failed ones) that hadn't been updated for six months // and every non failed contact that hadn't been updated for a month $condition = DBA::mergeConditions($base_condition, - ["(`last-update` < ? OR (NOT `archive` AND `last-update` < ?))", + ["(`last-update` < ? OR (NOT `failed` AND `last-update` < ?))", DateTimeFormat::utc('now - 6 month'), DateTimeFormat::utc('now - 1 month')]); $previous = count($ids); - $ids = self::getContactsToUpdate($condition, $ids, $limit - $previous); + $ids = self::getContactsToUpdate($condition, $limit - $previous, $ids); Logger::info('Fetched federated contacts', ['count' => count($ids) - $previous]); } @@ -96,12 +98,13 @@ class UpdateContacts * Returns contact ids based on a given condition * * @param array $condition + * @param int $limit * @param array $ids * @return array contact ids */ - private static function getContactsToUpdate(array $condition, array $ids = [], int $limit) + private static function getContactsToUpdate(array $condition, int $limit, array $ids = []) { - $contacts = DBA::select('contact', ['id'], $condition, ['limit' => $limit, 'order' => ['last-update']]); + $contacts = DBA::select('contact', ['id'], $condition, ['limit' => $limit]); while ($contact = DBA::fetch($contacts)) { $ids[$contact['id']] = $contact['id']; }