Scripts pour la reconstruction périodique de la table de recherche améliorée
authorx2000bedo <x2000bedo>
Sun, 15 Aug 2004 00:12:56 +0000 (00:12 +0000)
committerx2000bedo <x2000bedo>
Sun, 15 Aug 2004 00:12:56 +0000 (00:12 +0000)
Appeler :
- recherche.pl 1 toutes les 24 h
- recherche.pl 0 tous les 1/4 h
Attention ! Bien penser à mettre le flag (/tmp/flag_recherche) à 1 quand on change nom ou prénom ou
épouse.
Il faudra aussi bien vérifier que ça fonctionne vis-à-vis des droits au passage en prod.

scripts/cron/recherche.pl [new file with mode: 0755]
scripts/cron/recherche.sql [new file with mode: 0644]

diff --git a/scripts/cron/recherche.pl b/scripts/cron/recherche.pl
new file mode 100755 (executable)
index 0000000..a1a0c4f
--- /dev/null
@@ -0,0 +1,21 @@
+#! /usr/bin/perl -w
+
+my $mode = shift;
+#mode 1 = mise à jour obligatoire
+#mode autre = mise à jour si flag
+
+my @args = ("mysql x4dat <recherche.sql");
+
+if ($mode==1) {
+    system(@args);
+}
+else {
+    open(INFILE,'</tmp/flag_recherche');
+    $_ = <INFILE>;
+    system(@args)
+        if (/1/);
+    close INFILE;
+    open(OUTFILE,'>/tmp/flag_recherche');
+    print OUTFILE "0";
+    close OUTFILE;
+}
diff --git a/scripts/cron/recherche.sql b/scripts/cron/recherche.sql
new file mode 100644 (file)
index 0000000..3db8c2d
--- /dev/null
@@ -0,0 +1,6 @@
+USE x4dat;
+DROP TABLE recherche;
+CREATE TABLE recherche SELECT i.matricule AS matricule,LOWER(REPLACE(i.nom,'-',' ')) AS nom1,
+LOWER(REPLACE(u.nom,'-',' ')) AS nom2, LOWER(REPLACE(u.epouse,'-',' ')) AS nom3,
+LOWER(REPLACE(i.prenom,'-',' ')) AS prenom1, LOWER(REPLACE(u.prenom,'-',' ')) AS prenom2,i.promo AS
+promo FROM identification AS i LEFT JOIN auth_user_md5 AS u ON (u.matricule=i.matricule);