]> git.mxchange.org Git - friendica.git/commitdiff
New indexes for the API
authorMichael Vogel <icarus@dabo.de>
Tue, 19 Jul 2016 06:43:57 +0000 (08:43 +0200)
committerMichael Vogel <icarus@dabo.de>
Tue, 19 Jul 2016 06:43:57 +0000 (08:43 +0200)
boot.php
database.sql
include/Contact.php
include/api.php
include/dbstructure.php
include/ostatus.php
mod/content.php
update.php

index 298010dd0d36cd6060aea172d73213a4f70bcb69..8a92835e6807deb4f85441c66f59542deb1824ad 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_CODENAME',     'Asparagus');
 define ( 'FRIENDICA_VERSION',      '3.5-dev' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
-define ( 'DB_UPDATE_VERSION',      1199      );
+define ( 'DB_UPDATE_VERSION',      1200      );
 
 /**
  * @brief Constant with a HTML line break.
index 2b55a896f850f9c97f626d3309da364d4946989c..b27f69c40e4b5e0d971c28861aa3cc188d006ad5 100644 (file)
@@ -1,6 +1,6 @@
 -- ------------------------------------------
 -- Friendica 3.5-dev (Asparagus)
--- DB_UPDATE_VERSION 1199
+-- DB_UPDATE_VERSION 1200
 -- ------------------------------------------
 
 
@@ -522,6 +522,7 @@ CREATE TABLE IF NOT EXISTS `item` (
         INDEX `uid_title` (`uid`,`title`),
         INDEX `uid_thrparent` (`uid`,`thr-parent`),
         INDEX `uid_parenturi` (`uid`,`parent-uri`),
+        INDEX `uid_contactid_id` (`uid`,`contact-id`,`id`),
         INDEX `uid_contactid_created` (`uid`,`contact-id`,`created`),
         INDEX `gcontactid_uid_created` (`gcontact-id`,`uid`,`created`),
         INDEX `authorid_created` (`author-id`,`created`),
@@ -532,7 +533,7 @@ CREATE TABLE IF NOT EXISTS `item` (
         INDEX `uid_wall_created` (`uid`,`wall`,`created`),
         INDEX `resource-id` (`resource-id`),
         INDEX `uid_type` (`uid`,`type`),
-        INDEX `uid_starred` (`uid`,`starred`),
+        INDEX `uid_starred_id` (`uid`,`starred`,`id`),
         INDEX `contactid_allowcid_allowpid_denycid_denygid` (`contact-id`,`allow_cid`(10),`allow_gid`(10),`deny_cid`(10),`deny_gid`(10)),
         INDEX `uid_wall_parent_created` (`uid`,`wall`,`parent`,`created`),
         INDEX `uid_type_changed` (`uid`,`type`,`changed`),
index 10005d3e3caad6cd4c662601a8dc044f057980c3..9d69a81a4e1f7aad01dccb22ccd6e004c210fd4a 100644 (file)
@@ -631,11 +631,11 @@ function posts_from_contact($a, $contact_id) {
        $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`,
                        `author-name` AS `name`, `owner-avatar` AS `photo`,
                        `owner-link` AS `url`, `owner-avatar` AS `thumb`
-               FROM `item` FORCE INDEX (`uid_contactid_created`)
+               FROM `item` FORCE INDEX (`uid_contactid_id`)
                WHERE `item`.`uid` = %d AND `contact-id` = %d
                        AND `author-link` IN ('%s', '%s')
                        AND NOT `deleted` AND NOT `moderated` AND `visible`
-               ORDER BY `item`.`created` DESC LIMIT %d, %d",
+               ORDER BY `item`.`id` DESC LIMIT %d, %d",
                intval(local_user()),
                intval($contact_id),
                dbesc(str_replace("https://", "http://", $contact["url"])),
index ff2d083cc891ccd89aba8efac48f8cf33748e83d..af0fa600845ced56dc4b841aec4033147c70e59f 100644 (file)
                else {
                        // process normal login request
 
-                       $r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
-                               AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 LIMIT 1",
+                       $r = q("SELECT * FROM `user` WHERE (`email` = '%s' OR `nickname` = '%s')
+                               AND `password` = '%s' AND NOT `blocked` AND NOT `account_expired` AND NOT `account_removed` AND `verified` LIMIT 1",
                                dbesc(trim($user)),
                                dbesc(trim($user)),
                                dbesc($encrypted)
                        throw new UnauthorizedException("This API requires login");
                }
 
-               authenticate_success($record); $_SESSION["allow_api"] = true;
+               authenticate_success($record);
+
+               $_SESSION["allow_api"] = true;
 
                call_hooks('logged_in', $a->user);
 
                                return False;
                        } else {
                                $user = $_SESSION['uid'];
-                               $extra_query = "AND `contact`.`uid` = %d AND `contact`.`self` = 1 ";
+                               $extra_query = "AND `contact`.`uid` = %d AND `contact`.`self` ";
                        }
 
                }
                }
 
                if($uinfo[0]['self']) {
+
+                       if ($uinfo[0]['network'] == "")
+                               $uinfo[0]['network'] = NETWORK_DFRN;
+
                        $usr = q("select * from user where uid = %d limit 1",
                                intval(api_user())
                        );
                                        AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s')))
                                        AND `i`.`id` = `item`.`parent`
                                        AND `item`.`type`!='activity' $privacy_sql
-                               ORDER BY `item`.`created` DESC
+                               ORDER BY `item`.`id` DESC
                                LIMIT 1",
                                intval($user_info['cid']),
                                intval(api_user()),
         */
        function api_users_show(&$a, $type){
                $user_info = api_get_user($a);
-
                $lastwall = q("SELECT `item`.*
                                FROM `item`
                                INNER JOIN `contact` ON `contact`.`id`=`item`.`contact-id` AND `contact`.`uid` = `item`.`uid`
                                        AND ((`item`.`author-link` IN ('%s', '%s')) OR (`item`.`owner-link` IN ('%s', '%s')))
                                        AND `type`!='activity'
                                        AND `item`.`allow_cid`='' AND `item`.`allow_gid`='' AND `item`.`deny_cid`='' AND `item`.`deny_gid`=''
-                               ORDER BY `created` DESC
+                               ORDER BY `id` DESC
                                LIMIT 1",
                                intval(api_user()),
                                dbesc(ACTIVITY_POST),
 
                $sql_extra = '';
                if ($conversation)
-                       $sql_extra .= " AND `item`.`parent` = %d ORDER BY `received` ASC ";
+                       $sql_extra .= " AND `item`.`parent` = %d ORDER BY `id` ASC ";
                else
                        $sql_extra .= " AND `item`.`id` = %d";
 
index 10e1e0e625cbac35882db74f76d66ec679b3574a..bd35d0974ad51ced4386e9d2bda118a84d982402 100644 (file)
@@ -858,6 +858,7 @@ function db_definition() {
                                        "uid_title" => array("uid","title"),
                                        "uid_thrparent" => array("uid","thr-parent"),
                                        "uid_parenturi" => array("uid","parent-uri"),
+                                       "uid_contactid_id" => array("uid","contact-id","id"),
                                        "uid_contactid_created" => array("uid","contact-id","created"),
                                        "gcontactid_uid_created" => array("gcontact-id","uid","created"),
                                        "authorid_created" => array("author-id","created"),
@@ -868,7 +869,7 @@ function db_definition() {
                                        "uid_wall_created" => array("uid","wall","created"),
                                        "resource-id" => array("resource-id"),
                                        "uid_type" => array("uid","type"),
-                                       "uid_starred" => array("uid","starred"),
+                                       "uid_starred_id" => array("uid","starred", "id"),
                                        "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
                                        "uid_wall_parent_created" => array("uid","wall","parent","created"),
                                        "uid_type_changed" => array("uid","type","changed"),
index 7ac26846d246ab575259e89e5c6fa9a8fde632e7..ec53141dc7d06c386c8d070baddbfc1748e08c6a 100644 (file)
@@ -1971,7 +1971,7 @@ class ostatus {
                                                OR (`item`.`network` = '%s' AND ((`thread`.`network` IN ('%s', '%s')) OR (`thritem`.`network` IN ('%s', '%s')))) AND `thread`.`mention`)
                                        AND ((`item`.`owner-link` IN ('%s', '%s') AND (`item`.`parent` = `item`.`id`))
                                                OR (`item`.`author-link` IN ('%s', '%s')))
-                               ORDER BY `item`.`received` DESC
+                               ORDER BY `item`.`id` DESC
                                LIMIT 0, 300",
                                intval($owner["uid"]), dbesc($check_date), dbesc(NETWORK_DFRN),
                                //dbesc(NETWORK_OSTATUS), dbesc(NETWORK_OSTATUS),
index 54d499d4019dba4c5d766e4ef2e91097d6030547..c4b1f2f68f9a51a11d3f13b1e878544b970de9aa 100644 (file)
@@ -224,7 +224,7 @@ function content_content(&$a, $update = 0) {
                        $simple_update
                        AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
                        $sql_extra $sql_nets
-                       ORDER BY `item`.`received` DESC $pager_sql ",
+                       ORDER BY `item`.`id` DESC $pager_sql ",
                        intval($_SESSION['uid'])
                );
 
index 41f238e91300a0cd2bcae16ec3922c273d955181..8a8d93b1b94ed2b8339000256af8f37371496626 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define('UPDATE_VERSION' , 1199);
+define('UPDATE_VERSION' , 1200);
 
 /**
  *