Speeding up the gcontact search
This commit is contained in:
parent
f8c96d24b4
commit
017bfe17f8
2
boot.php
2
boot.php
|
@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica');
|
||||||
define ( 'FRIENDICA_CODENAME', 'Asparagus');
|
define ( 'FRIENDICA_CODENAME', 'Asparagus');
|
||||||
define ( 'FRIENDICA_VERSION', '3.5-dev' );
|
define ( 'FRIENDICA_VERSION', '3.5-dev' );
|
||||||
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
||||||
define ( 'DB_UPDATE_VERSION', 1194 );
|
define ( 'DB_UPDATE_VERSION', 1195 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Constant with a HTML line break.
|
* @brief Constant with a HTML line break.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 3.5-dev (Asparagus)
|
-- Friendica 3.5-dev (Asparagus)
|
||||||
-- DB_UPDATE_VERSION 1194
|
-- DB_UPDATE_VERSION 1195
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,7 +171,8 @@ CREATE TABLE IF NOT EXISTS `contact` (
|
||||||
`fetch_further_information` tinyint(1) NOT NULL DEFAULT 0,
|
`fetch_further_information` tinyint(1) NOT NULL DEFAULT 0,
|
||||||
`ffi_keyword_blacklist` mediumtext NOT NULL,
|
`ffi_keyword_blacklist` mediumtext NOT NULL,
|
||||||
PRIMARY KEY(`id`),
|
PRIMARY KEY(`id`),
|
||||||
INDEX `uid` (`uid`)
|
INDEX `uid` (`uid`),
|
||||||
|
INDEX `nurl` (`nurl`)
|
||||||
) DEFAULT CHARSET=utf8;
|
) DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -333,7 +334,9 @@ CREATE TABLE IF NOT EXISTS `gcontact` (
|
||||||
`generation` tinyint(3) NOT NULL DEFAULT 0,
|
`generation` tinyint(3) NOT NULL DEFAULT 0,
|
||||||
`server_url` varchar(255) NOT NULL DEFAULT '',
|
`server_url` varchar(255) NOT NULL DEFAULT '',
|
||||||
PRIMARY KEY(`id`),
|
PRIMARY KEY(`id`),
|
||||||
INDEX `nurl` (`nurl`),
|
INDEX `name` (`name`),
|
||||||
|
INDEX `nick` (`nick`),
|
||||||
|
INDEX `addr` (`addr`),
|
||||||
INDEX `updated` (`updated`)
|
INDEX `updated` (`updated`)
|
||||||
) DEFAULT CHARSET=utf8;
|
) DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ class DirSearch {
|
||||||
else
|
else
|
||||||
$extra_sql = "";
|
$extra_sql = "";
|
||||||
|
|
||||||
|
$search .= "%";
|
||||||
|
|
||||||
$results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`nick`, `gcontact`.`photo`,
|
$results = q("SELECT `contact`.`id` AS `cid`, `gcontact`.`url`, `gcontact`.`name`, `gcontact`.`nick`, `gcontact`.`photo`,
|
||||||
`gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`, `gcontact`.`community`
|
`gcontact`.`network`, `gcontact`.`keywords`, `gcontact`.`addr`, `gcontact`.`community`
|
||||||
FROM `gcontact`
|
FROM `gcontact`
|
||||||
|
@ -46,10 +48,10 @@ class DirSearch {
|
||||||
AND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')
|
AND NOT `contact`.`pending` AND `contact`.`rel` IN ('%s', '%s')
|
||||||
WHERE (`contact`.`id` > 0 OR (NOT `gcontact`.`hide` AND `gcontact`.`network` IN ('%s', '%s', '%s') AND
|
WHERE (`contact`.`id` > 0 OR (NOT `gcontact`.`hide` AND `gcontact`.`network` IN ('%s', '%s', '%s') AND
|
||||||
((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)))) AND
|
((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)))) AND
|
||||||
(`gcontact`.`addr` REGEXP '%s' OR `gcontact`.`name` REGEXP '%s' OR `gcontact`.`nick` REGEXP '%s') $extra_sql
|
(`gcontact`.`addr` LIKE '%s' OR `gcontact`.`name` LIKE '%s' OR `gcontact`.`nick` LIKE '%s') $extra_sql
|
||||||
GROUP BY `gcontact`.`nurl`
|
GROUP BY `gcontact`.`nurl`
|
||||||
ORDER BY `gcontact`.`nurl` DESC
|
ORDER BY `gcontact`.`nurl` DESC
|
||||||
LIMIT 40",
|
LIMIT 1000",
|
||||||
intval(local_user()), dbesc(CONTACT_IS_SHARING), dbesc(CONTACT_IS_FRIEND),
|
intval(local_user()), dbesc(CONTACT_IS_SHARING), dbesc(CONTACT_IS_FRIEND),
|
||||||
dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora),
|
dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora),
|
||||||
dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)));
|
dbesc(escape_tags($search)), dbesc(escape_tags($search)), dbesc(escape_tags($search)));
|
||||||
|
|
|
@ -508,6 +508,7 @@ function db_definition() {
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
"uid" => array("uid"),
|
"uid" => array("uid"),
|
||||||
|
"nurl" => array("nurl"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$database["conv"] = array(
|
$database["conv"] = array(
|
||||||
|
@ -669,7 +670,9 @@ function db_definition() {
|
||||||
),
|
),
|
||||||
"indexes" => array(
|
"indexes" => array(
|
||||||
"PRIMARY" => array("id"),
|
"PRIMARY" => array("id"),
|
||||||
"nurl" => array("nurl"),
|
"name" => array("name"),
|
||||||
|
"nick" => array("nick"),
|
||||||
|
"addr" => array("addr"),
|
||||||
"updated" => array("updated"),
|
"updated" => array("updated"),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
define( 'UPDATE_VERSION' , 1194 );
|
define('UPDATE_VERSION' , 1195);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user