quick search uses nicknames
authorPascal Corpet <pascal.corpet@m4x.org>
Mon, 9 May 2005 18:09:35 +0000 (18:09 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:28:56 +0000 (23:28 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-636

ChangeLog
bin/search.rebuild_db.php
include/profil/get_general.inc.php
include/profil/update_general.inc.php
include/user.func.inc.php
upgrade/0.9.7/update.sh [new file with mode: 0755]

index a721064..551f201 100644 (file)
--- 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 :
index 9812153..9aa22bd 100755 (executable)
@@ -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());
 }
 
index 2def19a..67ea33f 100644 (file)
@@ -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');
index 21add70..ea784a5 100644 (file)
@@ -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:
 ?>
index 95db763..a23ba67 100644 (file)
@@ -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 (executable)
index 0000000..de82fc0
--- /dev/null
@@ -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
+
+###########################################################
+