$totalResults = DBA::count('profile', ['net-publish' => true]);
} else {
$contacts = q("SELECT count(*) AS `total` FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
- AND (`success_update` >= `failure_update` OR `last-item` >= `failure_update`)
+ AND NOT `failed`
AND `network` IN ('%s', '%s', '%s', '%s') $sql_extra",
intval($user['uid']),
DBA::escape(Protocol::DFRN),
} else {
Logger::log("Start query for user " . $user['nickname'], Logger::DEBUG);
$contacts = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
- AND (`success_update` >= `failure_update` OR `last-item` >= `failure_update`)
+ AND NOT `failed`
AND `network` IN ('%s', '%s', '%s', '%s') $sql_extra LIMIT %d, %d",
intval($user['uid']),
DBA::escape(Protocol::DFRN),
$count = DBA::count('gcontact', [
'NOT `hide`
AND `network` IN (?, ?, ?, ?)
- AND ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`))
+ AND NOT `failed`
AND (`url` LIKE ? OR `name` LIKE ? OR `location` LIKE ?
OR `addr` LIKE ? OR `about` LIKE ? OR `keywords` LIKE ?)
AND `community` = ?',
$data = DBA::select('gcontact', ['nurl', 'name', 'addr', 'url', 'photo', 'network', 'keywords'], [
'NOT `hide`
AND `network` IN (?, ?, ?, ?)
- AND ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`))
+ AND NOT `failed`
AND (`url` LIKE ? OR `name` LIKE ? OR `location` LIKE ?
OR `addr` LIKE ? OR `about` LIKE ? OR `keywords` LIKE ?)
AND `community` = ?',
$results = DBA::p("SELECT `nurl` FROM `gcontact`
WHERE NOT `hide` AND `network` IN (?, ?, ?, ?) AND
- ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND
+ NOT `failed` AND
(`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?) $extra_sql
GROUP BY `nurl` ORDER BY `nurl` DESC LIMIT 1000",
Protocol::DFRN, Protocol::ACTIVITYPUB, $ostatus, $diaspora, $search, $search, $search
"SELECT count(*) as `total`
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
WHERE `glink`.`cid` = %d AND `glink`.`uid` = %d AND
- ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR
- (`gcontact`.`updated` >= `gcontact`.`last_failure`))
+ NOT `gcontact`.`failed`
AND `gcontact`.`nurl` IN (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d) ",
intval($cid),
intval($uid),
WHERE `glink`.`cid` = %d and `glink`.`uid` = %d
AND `contact`.`uid` = %d AND `contact`.`self` = 0 AND `contact`.`blocked` = 0
AND `contact`.`hidden` = 0 AND `contact`.`id` != %d
- AND ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`))
+ AND NOT `gcontact`.`failed`
$sql_extra LIMIT %d, %d",
intval($cid),
intval($uid),
"SELECT count(*) as `total`
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`cid` = %d and `glink`.`uid` = %d AND
- ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`))",
+ NOT `gcontact`.`failed`",
intval($cid),
intval($uid)
);
INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl` AND `contact`.`uid` = %d
WHERE `glink`.`cid` = %d AND `glink`.`uid` = %d AND
- ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`))
+ NOT `gcontact`.`failed`
ORDER BY `gcontact`.`name` ASC LIMIT %d, %d ",
intval($uid),
intval($cid),
AND NOT `gcontact`.`name` IN (SELECT `name` FROM `contact` WHERE `uid` = %d)
AND NOT `gcontact`.`id` IN (SELECT `gcid` FROM `gcign` WHERE `uid` = %d)
AND `gcontact`.`updated` >= '%s' AND NOT `gcontact`.`hide`
- AND `gcontact`.`last_contact` >= `gcontact`.`last_failure`
+ AND NOT `gcontact`.`failed`
AND `gcontact`.`network` IN (%s)
GROUP BY `glink`.`gcid` ORDER BY `gcontact`.`updated` DESC,`total` DESC LIMIT %d, %d",
intval($uid),
AND NOT `gcontact`.`name` IN (SELECT `name` FROM `contact` WHERE `uid` = %d)
AND NOT `gcontact`.`id` IN (SELECT `gcid` FROM `gcign` WHERE `uid` = %d)
AND `gcontact`.`updated` >= '%s'
- AND `gcontact`.`last_contact` >= `gcontact`.`last_failure`
+ AND NOT `gcontact`.`failed`
AND `gcontact`.`network` IN (%s)
ORDER BY rand() LIMIT %d, %d",
intval($uid),
$r = DBA::select('gserver', ['nurl', 'url'], [
'`network` = ?
- AND `last_contact` >= `last_failure`
+ AND NOT `failed`
AND `last_poco_query` < ?',
Protocol::OSTATUS,
$last_update
public static function getRandomUrl()
{
$r = DBA::selectFirst('gcontact', ['url'], [
- '`network` = ?
- AND `last_contact` >= `last_failure`
+ '`network` = ?
+ AND NOT `failed`
AND `updated` > ?',
Protocol::DFRN,
DateTimeFormat::utc('now - 1 month'),
$gservers = DBA::p("SELECT `id`, `url`, `nurl`, `network`, `poco`
FROM `gserver`
- WHERE `last_contact` >= `last_failure`
+ WHERE NOT `failed`
AND `poco` != ''
AND `last_poco_query` < ?
ORDER BY RAND()", $last_update
$gservers = DBA::p("SELECT COUNT(*) AS `total`, SUM(`registered-users`) AS `users`, `platform`,
ANY_VALUE(`network`) AS `network`, MAX(`version`) AS `version`
- FROM `gserver` WHERE `last_contact` >= `last_failure` GROUP BY `platform`");
+ FROM `gserver` WHERE NOT `failed` GROUP BY `platform`");
while ($gserver = DBA::fetch($gservers)) {
$total += $gserver['total'];
$users += $gserver['users'];
$versionCounts = [];
$versions = DBA::p("SELECT COUNT(*) AS `total`, `version` FROM `gserver`
- WHERE `last_contact` >= `last_failure` AND `platform` = ?
+ WHERE NOT `failed` AND `platform` = ?
GROUP BY `version` ORDER BY `version`", $gserver['platform']);
while ($version = DBA::fetch($versions)) {
$version['version'] = str_replace(["\n", "\r", "\t"], " ", $version['version']);
$return = [];
// We only select for Friendica and ActivityPub servers, since it is expected to only deliver AP compatible systems here.
- $instances = DBA::select('gserver', ['url'], ["`network` in (?, ?) AND `last_contact` >= `last_failure`", Protocol::DFRN, Protocol::ACTIVITYPUB]);
+ $instances = DBA::select('gserver', ['url'], ["`network` in (?, ?) AND NOT `failed`", Protocol::DFRN, Protocol::ACTIVITYPUB]);
while ($instance = DBA::fetch($instances)) {
$urldata = parse_url($instance['url']);
unset($urldata['scheme']);
if (!empty(DI::config()->get('system', 'nodeinfo'))) {
$stats->user_count = intval(DI::config()->get('nodeinfo', 'total_users'));
$stats->status_count = DI::config()->get('nodeinfo', 'local_posts') + DI::config()->get('nodeinfo', 'local_comments');
- $stats->domain_count = DBA::count('gserver', ["`network` in (?, ?) AND `last_contact` >= `last_failure`", Protocol::DFRN, Protocol::ACTIVITYPUB]);
+ $stats->domain_count = DBA::count('gserver', ["`network` in (?, ?) AND NOT `failed`", Protocol::DFRN, Protocol::ACTIVITYPUB]);
}
return $stats;
}
{
$r = q(
"SELECT `url`, `site_name` AS `displayName`, `network`, `platform`, `version` FROM `gserver`
- WHERE `network` IN ('%s', '%s', '%s') AND `last_contact` > `last_failure`
+ WHERE `network` IN ('%s', '%s', '%s') AND NOT `failed`
ORDER BY `last_contact`
LIMIT 1000",
DBA::escape(Protocol::DFRN),
if (!empty($j->results)) {
foreach ($j->results as $jj) {
// Check if the contact already exists
- $gcontact = DBA::selectFirst('gcontact', ['id', 'last_contact', 'last_failure', 'updated'], ['nurl' => Strings::normaliseLink($jj->url)]);
+ $gcontact = DBA::selectFirst('gcontact', ['failed'], ['nurl' => Strings::normaliseLink($jj->url)]);
if (DBA::isResult($gcontact)) {
Logger::info('Profile already exists', ['profile' => $jj->url, 'search' => $search]);
- if (($gcontact['last_contact'] < $gcontact['last_failure']) &&
- ($gcontact['updated'] < $gcontact['last_failure'])) {
+ if ($gcontact['failed']) {
continue;
}