Merge pull request #4019 from annando/develop
OnePoll now is called not so often anymore
This commit is contained in:
commit
c566ca74a5
2 changed files with 37 additions and 26 deletions
|
@ -153,14 +153,13 @@ Class Cron {
|
||||||
: ''
|
: ''
|
||||||
);
|
);
|
||||||
|
|
||||||
$contacts = q("SELECT `contact`.`id`, `contact`.`nick`, `contact`.`name`, `contact`.`network`,
|
$contacts = q("SELECT `contact`.`id`, `contact`.`nick`, `contact`.`name`, `contact`.`network`, `contact`.`archive`,
|
||||||
`contact`.`last-update`, `contact`.`priority`, `contact`.`subhub`
|
`contact`.`last-update`, `contact`.`priority`, `contact`.`rel`, `contact`.`subhub`
|
||||||
FROM `user`
|
FROM `user`
|
||||||
STRAIGHT_JOIN `contact`
|
STRAIGHT_JOIN `contact`
|
||||||
ON `contact`.`uid` = `user`.`uid` AND `contact`.`poll` != ''
|
ON `contact`.`uid` = `user`.`uid` AND `contact`.`poll` != ''
|
||||||
AND `contact`.`network` IN ('%s', '%s', '%s', '%s', '%s') $sql_extra
|
AND `contact`.`network` IN ('%s', '%s', '%s', '%s', '%s') $sql_extra
|
||||||
AND NOT `contact`.`self` AND NOT `contact`.`blocked` AND NOT `contact`.`readonly`
|
AND NOT `contact`.`self` AND NOT `contact`.`blocked`
|
||||||
AND NOT `contact`.`archive`
|
|
||||||
WHERE NOT `user`.`account_expired` AND NOT `user`.`account_removed` $abandon_sql",
|
WHERE NOT `user`.`account_expired` AND NOT `user`.`account_removed` $abandon_sql",
|
||||||
dbesc(NETWORK_DFRN),
|
dbesc(NETWORK_DFRN),
|
||||||
dbesc(NETWORK_OSTATUS),
|
dbesc(NETWORK_OSTATUS),
|
||||||
|
@ -179,6 +178,7 @@ Class Cron {
|
||||||
$contact['last-update'] = NULL_DATE;
|
$contact['last-update'] = NULL_DATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Friendica and OStatus are checked once a day
|
||||||
if (in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS))) {
|
if (in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS))) {
|
||||||
$contact['priority'] = 2;
|
$contact['priority'] = 2;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,17 @@ Class Cron {
|
||||||
* changed. We will only update hubs once a day, regardless of 'pushpoll_frequency'.
|
* changed. We will only update hubs once a day, regardless of 'pushpoll_frequency'.
|
||||||
*/
|
*/
|
||||||
$poll_interval = Config::get('system', 'pushpoll_frequency');
|
$poll_interval = Config::get('system', 'pushpoll_frequency');
|
||||||
$contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3);
|
$contact['priority'] = (!is_null($poll_interval) ? intval($poll_interval) : 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check Diaspora contacts or followers once a week
|
||||||
|
if (($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
|
||||||
|
$contact['priority'] = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check archived contacts once a month
|
||||||
|
if ($contact['archive']) {
|
||||||
|
$contact['priority'] = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($contact['priority'] >= 0) && !$force) {
|
if (($contact['priority'] >= 0) && !$force) {
|
||||||
|
@ -240,13 +250,16 @@ Class Cron {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact["nick"] . " " . $contact["name"]);
|
|
||||||
|
|
||||||
if (($contact['network'] == NETWORK_FEED) && ($contact['priority'] <= 3)) {
|
if (($contact['network'] == NETWORK_FEED) && ($contact['priority'] <= 3)) {
|
||||||
$priority = PRIORITY_MEDIUM;
|
$priority = PRIORITY_MEDIUM;
|
||||||
|
} elseif ($contact['archive']) {
|
||||||
|
$priority = PRIORITY_NEGLIGIBLE;
|
||||||
} else {
|
} else {
|
||||||
$priority = PRIORITY_LOW;
|
$priority = PRIORITY_LOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact['priority'] . " " . $contact["nick"] . " " . $contact["name"]);
|
||||||
|
|
||||||
Worker::add(array('priority' => $priority, 'dont_fork' => true), 'OnePoll', (int)$contact['id']);
|
Worker::add(array('priority' => $priority, 'dont_fork' => true), 'OnePoll', (int)$contact['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,27 +63,25 @@ Class OnePoll
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Diaspora users and followers we only check if they still exist.
|
// Diaspora users, archived users and followers are only checked if they still exist.
|
||||||
if (($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
|
if ($contact['archive'] || ($contact["network"] == NETWORK_DIASPORA) || ($contact["rel"] == CONTACT_IS_FOLLOWER)) {
|
||||||
if (PortableContact::updateNeeded($contact["created"], $contact["last-item"], $contact["failure_update"], $contact["success_update"])) {
|
$last_updated = PortableContact::lastUpdated($contact["url"]);
|
||||||
$last_updated = PortableContact::lastUpdated($contact["url"]);
|
$updated = datetime_convert();
|
||||||
$updated = datetime_convert();
|
if ($last_updated) {
|
||||||
if ($last_updated) {
|
logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
|
||||||
logger('Contact '.$contact['id'].' had last update on '.$last_updated, LOGGER_DEBUG);
|
|
||||||
|
|
||||||
// The last public item can be older than the last item we got
|
// The last public item can be older than the last item we got
|
||||||
if ($last_updated < $contact['last-item']) {
|
if ($last_updated < $contact['last-item']) {
|
||||||
$last_updated = $contact['last-item'];
|
$last_updated = $contact['last-item'];
|
||||||
}
|
|
||||||
|
|
||||||
$fields = array('last-item' => $last_updated, 'last-update' => $updated, 'success_update' => $updated);
|
|
||||||
self::updateContact($contact, $fields);
|
|
||||||
Contact::unmarkForArchival($contact);
|
|
||||||
} else {
|
|
||||||
self::updateContact($contact, array('last-update' => $updated, 'failure_update' => $updated));
|
|
||||||
Contact::markForArchival($contact);
|
|
||||||
logger('Contact '.$contact['id'].' is marked for archival', LOGGER_DEBUG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$fields = array('last-item' => $last_updated, 'last-update' => $updated, 'success_update' => $updated);
|
||||||
|
self::updateContact($contact, $fields);
|
||||||
|
Contact::unmarkForArchival($contact);
|
||||||
|
} else {
|
||||||
|
self::updateContact($contact, array('last-update' => $updated, 'failure_update' => $updated));
|
||||||
|
Contact::markForArchival($contact);
|
||||||
|
logger('Contact '.$contact['id'].' is marked for archival', LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue