]> git.mxchange.org Git - friendica.git/commitdiff
More joins replaced by view calls
authorMichael <heluecht@pirati.ca>
Fri, 24 Apr 2020 11:55:46 +0000 (11:55 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 24 Apr 2020 11:55:46 +0000 (11:55 +0000)
mod/poco.php
src/Worker/Directory.php
static/dbview.config.php

index f04ec42790f1a08b37fdd80dc2122ce07a331cdb..edbe73dceaffe825ceb1bc345f425764e71d8c8d 100644 (file)
@@ -81,10 +81,7 @@ function poco_init(App $a) {
        }
 
        if (!$system_mode && !$global) {
-               $user = DBA::fetchFirst("SELECT `user`.`uid`, `user`.`nickname` FROM `user`
-                       INNER JOIN `profile` ON `user`.`uid` = `profile`.`uid`
-                       WHERE `user`.`nickname` = ? AND NOT `profile`.`hide-friends`",
-                       $nickname);
+               $user = DBA::selectFirst('owner-view', ['uid', 'nickname'], ['nickname' => $nickname, 'hide-friends' => false]);
                if (!DBA::isResult($user)) {
                        throw new \Friendica\Network\HTTPException\NotFoundException();
                }
index ff844ca39209df506abbeb4042f1402f223d51c4..6c6d26f26cc35fcaf3bc29d4d8ce6e864ecbcf99 100644 (file)
@@ -61,16 +61,10 @@ class Directory
        }
 
        private static function updateAll() {
-               $r = q("SELECT `url` FROM `contact`
-                       INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid`
-                       INNER JOIN `user` ON `user`.`uid` = `contact`.`uid`
-                               WHERE `contact`.`self` AND `profile`.`net-publish` AND
-                                       NOT `user`.`account_expired` AND `user`.`verified`");
-
-               if (DBA::isResult($r)) {
-                       foreach ($r AS $user) {
-                               Worker::add(PRIORITY_LOW, 'Directory', $user['url']);
-                       }
+               $users = DBA::select('owner-view', ['url'], ['net-publish' => true, 'account_expired' => false, 'verified' => true]);
+               while ($user = DBA::fetch($users)) {
+                       Worker::add(PRIORITY_LOW, 'Directory', $user['url']);
                }
+               DBA::close($users);
        }
 }
index 0d44df03111afeb676b55b31a82c701743f3e260..0fd4048ca729af95212495454179a178f8f63e4b 100755 (executable)
@@ -105,9 +105,9 @@ return [
                        "avatar-date" => ["contact", "avatar-date"],
                        "term-date" => ["contact", "term-date"],
                        "last-item" => ["contact", "last-item"],                        
-                       "lastitem_date" => ["contact", "last-item"],
+                       "lastitem_date" => ["contact", "last-item"], /// @todo Replaces all uses of "lastitem_date" with "last-item"
                        "priority" => ["contact", "priority"],
-                       "blocked" => ["contact", "blocked"],
+                       "blocked" => ["contact", "blocked"], /// @todo Check if "blocked" from contact or from the users table
                        "block_reason" => ["contact", "block_reason"],
                        "readonly" => ["contact", "readonly"],
                        "writable" => ["contact", "writable"],
@@ -133,8 +133,9 @@ return [
                        "ffi_keyword_blacklist" => ["ffi_keyword_blacklist"],
                        "email" => ["user", "email"],
                        "uprvkey" => ["user", "prvkey"],
+                       "upubkey" => ["user", "pubkey"],
                        "timezone" => ["user", "timezone"],
-                       "nickname" => ["user", "nickname"],
+                       "nickname" => ["user", "nickname"], /// @todo Remove duplicate
                        "sprvkey" => ["user", "sprvkey"],
                        "spubkey" => ["user", "spubkey"],
                        "page-flags" => ["user", "page-flags"],
@@ -145,12 +146,28 @@ return [
                        "login_date" => ["user", "login_date"],
                        "register_date" => ["user", "register_date"],
                        "verified" => ["user", "verified"],
+                       "expire" => ["user", "expire"],
+                       "expire_notification_sent" => ["user", "expire_notification_sent"],                     
                        "account_removed" => ["user", "account_removed"],
                        "account_expired" => ["user", "account_expired"],
                        "account_expires_on" => ["user", "account_expires_on"],
+                       "publish" => ["profile", "publish"],
+                       "net-publish" => ["profile", "net-publish"],
+                       "hide-friends" => ["profile", "hide-friends"],
+                       "prv_keywords" => ["profile", "prv_keywords"],
+                       "pub_keywords" => ["profile", "pub_keywords"],
+                       "address" => ["profile", "address"],
+                       "locality" => ["profile", "locality"],
+                       "region" => ["profile", "region"],
+                       "postal-code" => ["profile", "postal-code"],
+                       "country-name" => ["profile", "country-name"],
+                       "homepage" => ["profile", "homepage"],
+                       "xmpp" => ["profile", "xmpp"],
+                       "dob" => ["profile", "dob"],
                ],
                "query" => "FROM `user`
-                       INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`"
+                       INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
+                       INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`"
        ]
 ];