]> git.mxchange.org Git - friendica.git/commitdiff
Use "failed" field
authorMichael <heluecht@pirati.ca>
Sun, 19 Jul 2020 11:42:23 +0000 (11:42 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 19 Jul 2020 11:42:23 +0000 (11:42 +0000)
mod/poco.php
src/Core/Search.php
src/Model/GContact.php
src/Model/GServer.php
src/Module/Admin/Federation.php
src/Module/Api/Mastodon/Instance/Peers.php
src/Object/Api/Mastodon/Stats.php
src/Protocol/PortableContact.php
src/Worker/SearchDirectory.php

index f1fdc55d7560bbca78b88c82443a4fcfaeaf96aa..abe10ee39cc2ef7a56540ab9008b354ae3ebf39a 100644 (file)
@@ -110,7 +110,7 @@ function poco_init(App $a) {
                $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),
@@ -148,7 +148,7 @@ function poco_init(App $a) {
        } 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),
index ea979610e6c20d33984bafc320f887598401f87e..edc88ffd7d4fa004c2ae8034b99d77ac5c8dafa7 100644 (file)
@@ -180,7 +180,7 @@ class Search
                $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` = ?',
@@ -199,7 +199,7 @@ class Search
                $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` = ?',
index 00867475a8a404d05ed3a37872e0418fa03f4b73..6a3c7da74cbada7e4fc0f399ab22c91f497af87d 100644 (file)
@@ -95,7 +95,7 @@ class GContact
 
                $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
@@ -274,8 +274,7 @@ class GContact
                        "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),
@@ -338,7 +337,7 @@ class GContact
                        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),
@@ -397,7 +396,7 @@ class GContact
                        "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)
                );
@@ -425,7 +424,7 @@ class GContact
                        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),
@@ -472,7 +471,7 @@ class GContact
                        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),
@@ -496,7 +495,7 @@ class GContact
                        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),
@@ -1270,7 +1269,7 @@ class GContact
 
                $r = DBA::select('gserver', ['nurl', 'url'], [
                        '`network` = ?
-                       AND `last_contact` >= `last_failure`
+                       AND NOT `failed`
                        AND `last_poco_query` < ?',
                        Protocol::OSTATUS,
                        $last_update
@@ -1421,8 +1420,8 @@ class GContact
        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'),
index 23056906c2e9f2a198c20d244ed5dd22120f37e3..3d268c37b91f699bb0c4950f2c64636b9d828901 100644 (file)
@@ -1587,7 +1587,7 @@ class GServer
 
                $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
index 928a286b14ebf7a42e9ad27e632e256e37f42271..fd60b071526b88fc65e3b8106342db0554c72548 100644 (file)
@@ -64,14 +64,14 @@ class Federation extends BaseAdmin
 
                $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']);
index 82f08cbad0eccad9c5f6bc1a7b4caaa5a3e58a1d..537d25e28c3c93ccc1c7d2abb18eb82b4ed5b4af 100644 (file)
@@ -42,7 +42,7 @@ class Peers extends BaseApi
                $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']);
index 8677cf04252b9bc0cf81964142c3103c9cfd78f0..6ead5267294ced3aec93e555c306431eadd8dd5a 100644 (file)
@@ -51,7 +51,7 @@ class Stats extends BaseEntity
                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;
        }
index f255347c1284e62e87ad963771dabec48c55c6fa..d66676cac5699eb0fac6e802bd5717a5685a3535 100644 (file)
@@ -228,7 +228,7 @@ class PortableContact
        {
                $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),
index 2ffe6120ec56e950b24278ca776079ae3b2e1dc7..afe54e5fb1ee4fb70ec3ad6808447e07fbfeb69f 100644 (file)
@@ -58,12 +58,11 @@ class SearchDirectory
                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;
                                        }