From: Pascal Corpet Date: Mon, 9 May 2005 18:09:35 +0000 (+0000) Subject: quick search uses nicknames X-Git-Tag: xorg/old~126 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=9da943daaed9694b981257c6e67687304f787071;p=platal.git quick search uses nicknames git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-636 --- diff --git a/ChangeLog b/ChangeLog index a721064..551f201 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,12 @@ ================================================================================ +VERSION 0.9.7 07 May 2004 + +New : + + * Search : + - Nickname are used in fast search. -Car + +================================================================================ VERSION 0.9.6 07 May 2004 New : diff --git a/bin/search.rebuild_db.php b/bin/search.rebuild_db.php index 9812153..9aa22bd 100755 --- a/bin/search.rebuild_db.php +++ b/bin/search.rebuild_db.php @@ -26,11 +26,12 @@ require('user.func.inc.php'); ini_set('memory_limit', "16M"); $globals->xdb->execute('DELETE FROM search_name'); -$res = $globals->xdb->iterRow('SELECT user_id, nom, prenom, nom_usage FROM auth_user_md5'); +$res = $globals->xdb->iterRow('SELECT auth_user_md5.user_id, nom, prenom, nom_usage, profile_nick FROM auth_user_md5 INNER JOIN auth_user_quick USING(user_id)'); $i = 0; +$muls = array(1,1,1,0.2); while ($tmp = $res->next()) { $uid = array_shift($tmp); - _user_reindex($uid, $tmp); + _user_reindex($uid, $tmp, $muls); printf ("%02.2f %%\n", ++$i*100/$res->total()); } diff --git a/include/profil/get_general.inc.php b/include/profil/get_general.inc.php index 2def19a..67ea33f 100644 --- a/include/profil/get_general.inc.php +++ b/include/profil/get_general.inc.php @@ -40,6 +40,7 @@ $photo_pub = $result->fetchOneCell(); $nom_anc = $nom; $prenom_anc = $prenom; $nationalite_anc = $nationalite; +$nickname_anc = $nickname; replace_ifset($nom,'nom'); replace_ifset($prenom,'prenom'); diff --git a/include/profil/update_general.inc.php b/include/profil/update_general.inc.php index 21add70..ea784a5 100644 --- a/include/profil/update_general.inc.php +++ b/include/profil/update_general.inc.php @@ -49,6 +49,10 @@ $globals->xdb->execute( $freetext, $freetext_pub, Session::getInt('uid', -1)); +if ($nickname != $nickname_anc) { + require_once('user.func.inc.php'); + user_reindex(Session::getInt('uid', -1)); +} $globals->xdb->execute("UPDATE photo SET pub = {?} WHERE uid = {?}", $photo_pub, Session::getInt('uid', -1)); // vim:set et sws=4 sts=4 sw=4: ?> diff --git a/include/user.func.inc.php b/include/user.func.inc.php index 95db763..a23ba67 100644 --- a/include/user.func.inc.php +++ b/include/user.func.inc.php @@ -255,9 +255,9 @@ function &get_user_details($login, $from_uid = '') // }}} // {{{ function _user_reindex -function _user_reindex($uid, $keys) { +function _user_reindex($uid, $keys, $muls) { global $globals; - foreach ($keys as $key) { + foreach ($keys as $i => $key) { if ($key == '') { continue; } @@ -266,7 +266,7 @@ function _user_reindex($uid, $keys) { $first = 5; while ($toks) { $token = strtolower(replace_accent(array_pop($toks) . $token)); - $score = ($toks ? 0 : 10 + $first); + $score = ($toks ? 0 : 10 + $first) * $muls[$i]; mysql_query("REPLACE INTO search_name (token, uid, score) VALUES('$token',$uid,$score)"); $first = 0; } @@ -279,8 +279,8 @@ function _user_reindex($uid, $keys) { function user_reindex($uid) { global $globals; $globals->xdb->execute("DELETE FROM search_name WHERE uid={?}", $uid); - $res = $globals->xdb->query("SELECT prenom, nom, nom_usage FROM auth_user_md5 WHERE user_id = {?}", $uid); - _user_reindex($uid, $res->fetchOneRow()); + $res = $globals->xdb->query("SELECT prenom, nom, nom_usage, profile_nick FROM auth_user_md5 INNER JOIN auth_user_quick USING(user_id) WHERE auth_user_md5.user_id = {?}", $uid); + _user_reindex($uid, $res->fetchOneRow(), array(1,1,1,0.2)); } // }}} diff --git a/upgrade/0.9.7/update.sh b/upgrade/0.9.7/update.sh new file mode 100755 index 0000000..de82fc0 --- /dev/null +++ b/upgrade/0.9.7/update.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +. ../inc/pervasive.sh + +mailman_stop +mailman_templates +mailman_start + + +########################################################### +for sql in *.sql +do + echo -n $sql + $MYSQL x4dat < $sql &>/dev/null || echo -n " ERROR" + echo . +done + +########################################################### + +echo "we will now upgrade the search table (this may be a long operation) + +please hit ^D to continue +" + +cat + +pushd ../../bin +./search.rebuild_db.php +popd + +########################################################### +