From fa829b82f023ed9a740c73629379eb4a747d61c5 Mon Sep 17 00:00:00 2001
From: Pascal Corpet
Date: Mon, 17 Jan 2005 00:31:40 +0000
Subject: [PATCH] wish 261 : courbe d'evolution du nb d'inscrits
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-366
---
ChangeLog | 5 +-
htdocs/stats/evolution_inscrits.php | 27 +++++++++++
htdocs/stats/graph_evolution.php | 85 ++++++++++++++++++++++++++++++++++
templates/stats/evolution_inscrits.tpl | 52 +++++++++++++++++++++
templates/stats/index.tpl | 1 +
5 files changed, 169 insertions(+), 1 deletion(-)
create mode 100644 htdocs/stats/evolution_inscrits.php
create mode 100644 htdocs/stats/graph_evolution.php
create mode 100644 templates/stats/evolution_inscrits.tpl
diff --git a/ChangeLog b/ChangeLog
index b43e46b..ecedcce 100644
--- 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
index 0000000..2534d7f
--- /dev/null
+++ b/htdocs/stats/evolution_inscrits.php
@@ -0,0 +1,27 @@
+run();
+
+?>
diff --git a/htdocs/stats/graph_evolution.php b/htdocs/stats/graph_evolution.php
new file mode 100644
index 0000000..ddd8546
--- /dev/null
+++ b/htdocs/stats/graph_evolution.php
@@ -0,0 +1,85 @@
+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 = <<
diff --git a/templates/stats/evolution_inscrits.tpl b/templates/stats/evolution_inscrits.tpl
new file mode 100644
index 0000000..e07f11b
--- /dev/null
+++ b/templates/stats/evolution_inscrits.tpl
@@ -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 *
+ ***************************************************************************}
+
+
+
+ Evolution du nombre d'inscrits au site polytechnique.org
+
+
+
+{if $smarty.request.jours eq 1826}
+[
depuis 5 ans]
+{else}
+[
depuis 5 ans]
+{/if}
+{if $smarty.request.jours eq 731}
+[
depuis 2 ans]
+{else}
+[
depuis 2 ans]
+{/if}
+{if (!$smarty.request.jours) or ($smarty.request.jours eq 364)}
+[
depuis un an]
+{else}
+[
depuis un an]
+{/if}
+{if $smarty.request.jours eq 30}
+[
depuis un mois]
+{else}
+[
depuis 1 mois]
+{/if}
+
+
+
![[ INSCRITS ]]({)
+
+
+{* vim:set et sw=2 sts=2 sws=2: *}
diff --git a/templates/stats/index.tpl b/templates/stats/index.tpl
index be4ee82..1e06883 100644
--- a/templates/stats/index.tpl
+++ b/templates/stats/index.tpl
@@ -28,6 +28,7 @@ Quelques statistiques sur l'utilisation des services de Polytechnique.org ainsi