wish 261 : courbe d'evolution du nb d'inscrits
authorPascal Corpet <pascal.corpet@m4x.org>
Mon, 17 Jan 2005 00:31:40 +0000 (00:31 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:45 +0000 (23:27 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-366

ChangeLog
htdocs/stats/evolution_inscrits.php [new file with mode: 0644]
htdocs/stats/graph_evolution.php [new file with mode: 0644]
templates/stats/evolution_inscrits.tpl [new file with mode: 0644]
templates/stats/index.tpl

index b43e46b..ecedcce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -77,7 +77,10 @@ Bug/Wish :
 
        * Search :
                - #249, #251, #253 : Some tweaks to be more accurate.                           -MC
-       
+
+       * Stats :
+               - #261: Stats of registrations over the time.                       -Car
+               
        * Validations :
                - #137: Now possible to add comments without any action.                        -MC
                - #191, #256: Marketing now uses the validation process.                        -MC
diff --git a/htdocs/stats/evolution_inscrits.php b/htdocs/stats/evolution_inscrits.php
new file mode 100644 (file)
index 0000000..2534d7f
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+require_once("xorg.inc.php");
+new_skinned_page("stats/evolution_inscrits.tpl", AUTH_COOKIE);
+
+$page->run();
+
+?>
diff --git a/htdocs/stats/graph_evolution.php b/htdocs/stats/graph_evolution.php
new file mode 100644 (file)
index 0000000..ddd8546
--- /dev/null
@@ -0,0 +1,85 @@
+<?php
+/***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************/
+
+require_once("xorg.inc.php");
+
+new_skinned_page('index.tpl', AUTH_COOKIE);
+
+//nombre de jours sur le graph
+$JOURS=Env::getInt('jours', 364);
+define('DUREEJOUR',24*3600);
+
+//recupere le nombre d'inscriptions par jour sur la plage concernée
+$res = $globals->xdb->iterRow(
+        "SELECT  IF( date_ins>DATE_SUB(NOW(),INTERVAL $JOURS DAY),
+                     TO_DAYS(date_ins)-TO_DAYS(NOW()),
+                    ".(-($JOURS+1)).") AS jour,
+                 COUNT(user_id) AS nb
+           FROM  auth_user_md5 
+          WHERE  perms IN ('admin','user')
+       GROUP BY  jour");
+
+//genere des donnees compatibles avec GNUPLOT
+$inscrits='';
+
+// la première ligne contient le total des inscrits avant la date de départ (J - $JOURS)
+list(,$init_nb) = $res->next();
+$total = $init_nb;
+
+list($numjour, $nb) = $res->next();
+
+for ($i=-$JOURS;$i<=0;$i++) {
+    if ($numjour<$i) {
+        if(!list($numjour, $nb) = $res->next()) {
+            $numjour = 0;
+            $nb = 0;
+        }
+    }
+    if ($numjour==$i) $total+=$nb;
+    $inscrits .= date('d/m/y',$i*DUREEJOUR+time())." ".$total."\n";
+}
+
+//Genere le graphique à la volée avec GNUPLOT
+header( "Content-type: image/png");
+
+$ymin = round($init_nb*0.95,0);
+$ymax = round($total  *1.05,0);
+
+$gnuplot = <<<EOF2
+gnuplot <<EOF
+
+set term png small color
+set size 640/480
+set xdata time
+set timefmt "%d/%m/%y"
+
+set format x "%m/%y"
+set yr [$ymin:$ymax]
+
+set title "Nombre d'inscrits"
+
+plot "-" using 1:2 title 'inscrits' with lines;
+{$inscrits}
+EOF
+EOF2;
+
+passthru($gnuplot);
+?>
diff --git a/templates/stats/evolution_inscrits.tpl b/templates/stats/evolution_inscrits.tpl
new file mode 100644 (file)
index 0000000..e07f11b
--- /dev/null
@@ -0,0 +1,52 @@
+{***************************************************************************
+ *  Copyright (C) 2003-2004 Polytechnique.org                              *
+ *  http://opensource.polytechnique.org/                                   *
+ *                                                                         *
+ *  This program is free software; you can redistribute it and/or modify   *
+ *  it under the terms of the GNU General Public License as published by   *
+ *  the Free Software Foundation; either version 2 of the License, or      *
+ *  (at your option) any later version.                                    *
+ *                                                                         *
+ *  This program is distributed in the hope that it will be useful,        *
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+ *  GNU General Public License for more details.                           *
+ *                                                                         *
+ *  You should have received a copy of the GNU General Public License      *
+ *  along with this program; if not, write to the Free Software            *
+ *  Foundation, Inc.,                                                      *
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
+ ***************************************************************************}
+
+
+<h1>
+  Evolution du nombre d'inscrits au site polytechnique.org
+</h1>
+
+<div class="center">
+{if $smarty.request.jours eq 1826}
+[<strong>depuis 5 ans</strong>]
+{else}
+[<a href="?jours=1826">depuis 5 ans</a>]
+{/if}
+{if $smarty.request.jours eq 731}
+[<strong>depuis 2 ans</strong>]
+{else}
+[<a href="?jours=731">depuis 2 ans</a>]
+{/if}
+{if (!$smarty.request.jours) or ($smarty.request.jours eq 364)}
+[<strong>depuis un an</strong>]
+{else}
+[<a href="?jours=364">depuis un an</a>]
+{/if}
+{if $smarty.request.jours eq 30}
+[<strong>depuis un mois</strong>]
+{else}
+[<a href="?jours=30">depuis 1 mois</a>]
+{/if}
+</div>
+<div class="center">
+  <img src="{"stats/graph_evolution.php?jours="|url}{$smarty.request.jours}" alt=" [ INSCRITS ] " />
+</div>
+
+{* vim:set et sw=2 sts=2 sws=2: *}
index be4ee82..1e06883 100644 (file)
@@ -28,6 +28,7 @@ Quelques statistiques sur l'utilisation des services de Polytechnique.org ainsi
 </p>
 
 <ul>
+<li><a href="evolution_inscrits.php">Nombre d'inscrits au cours du temps</a></li>
 <li><a href="stats_promo.php">Nombre d'inscrits dans ta promotion</a></li>
 <li><a href="nb_by_promo.php">Nombre d'inscrits par promotion</a></li>
 <li><a href="parselog.php">Statistiques mail</a></li>