1818 |
jpm |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* Statistiques par année sur l'utilisation de Identiplante / Pictoflora
|
|
|
4 |
*
|
|
|
5 |
* @see Documentation : <http://www.tela-botanica.org/wikini/DevInformatiques/wakka.php?wiki=AppliDelStats>
|
|
|
6 |
*
|
|
|
7 |
* @category DEL
|
|
|
8 |
* @package Services
|
|
|
9 |
* @subpackage Statistiques
|
|
|
10 |
* @version 0.1
|
|
|
11 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
|
|
12 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
13 |
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
|
|
|
14 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
|
|
15 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
|
|
16 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
|
|
17 |
*/
|
|
|
18 |
class StatistiquesParAnnee {
|
|
|
19 |
|
|
|
20 |
private $conteneur;
|
|
|
21 |
private $contexte;
|
|
|
22 |
private $navigation;
|
|
|
23 |
private $bdd;
|
|
|
24 |
|
|
|
25 |
private $annee = null;
|
|
|
26 |
private $type = 'tout';
|
|
|
27 |
private $methode = '';
|
|
|
28 |
|
|
|
29 |
public function __construct(Conteneur $conteneur = null) {
|
|
|
30 |
$this->conteneur = $conteneur == null ? new Conteneur() : $conteneur;
|
|
|
31 |
$this->contexte = $conteneur->getContexte();
|
|
|
32 |
$this->navigation = $conteneur->getNavigation();
|
|
|
33 |
$this->bdd = $this->conteneur->getBdd();
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
public function consulter() {
|
|
|
37 |
$this->intitialiserParametresEtRessources();
|
|
|
38 |
$this->verifierPreRequis();
|
|
|
39 |
|
|
|
40 |
$resultat = new ResultatService();
|
|
|
41 |
$resultat->corps = call_user_func(array($this, $this->methode));
|
|
|
42 |
return $resultat;
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
private function intitialiserParametresEtRessources() {
|
|
|
46 |
$this->type = $this->contexte->getRessource(2) != null ? $this->contexte->getRessource(2) : $this->type;
|
|
|
47 |
$this->methode = $this->obtenirNomMethode($this->type);
|
|
|
48 |
$this->annee =(int) $this->contexte->getQS('annee') != null ? intval($this->contexte->getQS('annee')) : null;
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
private function verifierPreRequis() {
|
|
|
52 |
$erreurs = array();
|
|
|
53 |
|
|
|
54 |
if ($this->annee != null && !is_int($this->annee)) {
|
|
|
55 |
$erreurs[] = "Le paramètre 'annee' doit être un entier.";
|
|
|
56 |
}
|
|
|
57 |
if (method_exists($this, $this->obtenirNomMethode($this->type)) === false) {
|
|
|
58 |
$erreurs[] = "Les stats de type '{$this->type}' n'existent pas.";
|
|
|
59 |
}
|
|
|
60 |
if (!empty($erreurs)) {
|
|
|
61 |
$msg = "Erreur de configuration :\n".implode("\n", $erreurs)."\n\n".Statistiques::getDoc();
|
|
|
62 |
throw new Exception($msg, RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
|
|
|
63 |
}
|
|
|
64 |
}
|
|
|
65 |
|
2011 |
mathias |
66 |
/**
|
|
|
67 |
* Ouh la jolie méthode magique !!
|
|
|
68 |
* @param unknown $mot
|
|
|
69 |
* @return string
|
|
|
70 |
*/
|
1818 |
jpm |
71 |
private function obtenirNomMethode($mot) {
|
|
|
72 |
$classeNom = 'get'.str_replace(' ', '', ucwords(strtolower(str_replace('-', ' ', $mot))));
|
|
|
73 |
return $classeNom;
|
|
|
74 |
}
|
|
|
75 |
|
2011 |
mathias |
76 |
/**
|
2016 |
mathias |
77 |
* Statistiques sur les observations
|
|
|
78 |
* "MPM" = moyenne par mois
|
|
|
79 |
* "TC" = tag à déterminer ou certitude incertaine
|
|
|
80 |
* - Nombre d'observations au total
|
|
|
81 |
* - Nombre d'obs sans identification (ou tag ou certitude)
|
|
|
82 |
* - Nombre d'obs sans identification
|
|
|
83 |
* - Nombre d'obs avec tag à déterminer ou certitude incertaine
|
|
|
84 |
* - Nombre d'obs avec tag à déterminer ou certitude incertaine et retenue
|
|
|
85 |
* - Nombre d'obs avec tag à déterminer ou certitude incertaine et avec consensus
|
|
|
86 |
* - Nombre d'obs avec tag à déterminer ou certitude incertaine et avec consensus mais non validées
|
2020 |
mathias |
87 |
* - Nombre d'observations ayant une proposition retenue (parmi les observations de l'année)
|
|
|
88 |
* - Nombre d'observations ayant une proposition retenue ou en consensus (parmi les observations de l'année)
|
2016 |
mathias |
89 |
*/
|
|
|
90 |
private function getObservations() {
|
2021 |
mathias |
91 |
$nbObsTotal = $this->getNbObsTotal();
|
|
|
92 |
$nbObsSansIdentOuTC = $this->getNbObsSansIdentOuTC();
|
|
|
93 |
$nbObsSansIdent = $this->getNbObsSansIdent();
|
|
|
94 |
$nbObsTC = $this->getNbObsTC();
|
|
|
95 |
$nbObsTCRetenue = $this->getNbObsTCRetenue();
|
|
|
96 |
$nbObsTCConsensus = $this->getNbObsTCConsensus();
|
|
|
97 |
$nbObsTCConsensusNonValide = $this->getNbObsTCConsensusNonValide();
|
|
|
98 |
$nbPropositionsRetenuesObsAnnee = $this->getNbPropositionsRetenuesObsAnnee();
|
|
|
99 |
$nbPropositionsConsensusObsAnnee = $this->getNbPropositionsConsensusObsAnnee();
|
1818 |
jpm |
100 |
return array(
|
2021 |
mathias |
101 |
'nbObsTotal' => $nbObsTotal,
|
2016 |
mathias |
102 |
'nbObsTotalMPM' => $this->getNbObsTotal(true),
|
2021 |
mathias |
103 |
'nbObsSansIdentOuTC' => $nbObsSansIdentOuTC,
|
2016 |
mathias |
104 |
'nbObsSansIdentOuTCMPM' => $this->getNbObsSansIdentOuTC(true),
|
2022 |
mathias |
105 |
'nbObsSansIdentOuTCPC' => $nbObsTotal == 0 ? 0 : round(($nbObsSansIdentOuTC / $nbObsTotal) * 100, 2),
|
2021 |
mathias |
106 |
'nbObsSansIdent' => $nbObsSansIdent,
|
2016 |
mathias |
107 |
'nbObsSansIdentMPM' => $this->getNbObsSansIdent(true),
|
2022 |
mathias |
108 |
'nbObsSansIdentPC' => $nbObsTotal == 0 ? 0 : round(($nbObsSansIdent / $nbObsTotal) * 100, 2),
|
2021 |
mathias |
109 |
'nbObsTC' => $nbObsTC,
|
2016 |
mathias |
110 |
'nbObsTCMPM' => $this->getNbObsTC(true),
|
2022 |
mathias |
111 |
'nbObsTCPC' => $nbObsTotal == 0 ? 0 : round(($nbObsTC / $nbObsTotal) * 100, 2),
|
2021 |
mathias |
112 |
'nbObsTCRetenue' => $nbObsTCRetenue,
|
2017 |
mathias |
113 |
'nbObsTCRetenueMPM' => $this->getNbObsTCRetenue(true),
|
2022 |
mathias |
114 |
'nbObsTCRetenuePC' => $nbObsTotal == 0 ? 0 : round(($nbObsTCRetenue / $nbObsTotal) * 100, 2),
|
2021 |
mathias |
115 |
'nbObsTCConsensus' => $nbObsTCConsensus,
|
2016 |
mathias |
116 |
'nbObsTCConsensusMPM' => $this->getNbObsTCConsensus(true),
|
2022 |
mathias |
117 |
'nbObsTCConsensusPC' => $nbObsTotal == 0 ? 0 : round(($nbObsTCConsensus / $nbObsTotal) * 100, 2),
|
2021 |
mathias |
118 |
'nbObsTCConsensusNonValide' => $nbObsTCConsensusNonValide,
|
2016 |
mathias |
119 |
'nbObsTCConsensusNonValideMPM' => $this->getNbObsTCConsensusNonValide(true),
|
2022 |
mathias |
120 |
'nbObsTCConsensusNonValidePC' => $nbObsTotal == 0 ? 0 : round(($nbObsTCConsensusNonValide / $nbObsTotal) * 100, 2),
|
2021 |
mathias |
121 |
'nbPropositionsRetenuesObsAnnee' => $nbPropositionsRetenuesObsAnnee,
|
2020 |
mathias |
122 |
'nbPropositionsRetenuesObsAnneeMPM' => $this->getNbPropositionsRetenuesObsAnnee(true),
|
2022 |
mathias |
123 |
'nbPropositionsRetenuesObsAnneePC' => $nbObsTotal == 0 ? 0 : round(($nbPropositionsRetenuesObsAnnee / $nbObsTotal) * 100, 2),
|
2021 |
mathias |
124 |
'nbPropositionsConsensusObsAnnee' => $nbPropositionsConsensusObsAnnee,
|
2020 |
mathias |
125 |
'nbPropositionsConsensusObsAnneeMPM' => $this->getNbPropositionsConsensusObsAnnee(true),
|
2022 |
mathias |
126 |
'nbPropositionsConsensusObsAnneePC' => $nbObsTotal == 0 ? 0 : round(($nbPropositionsConsensusObsAnnee / $nbObsTotal) * 100, 2),
|
1818 |
jpm |
127 |
);
|
|
|
128 |
}
|
|
|
129 |
|
2016 |
mathias |
130 |
/**
|
|
|
131 |
* Nombre d'observations au total
|
|
|
132 |
*/
|
|
|
133 |
private function getNbObsTotal($mpm=false) {
|
|
|
134 |
$requete = "SELECT COUNT(id_observation) AS nb_total FROM del_observation";
|
|
|
135 |
if ($this->annee != null) {
|
|
|
136 |
$requete .= ' WHERE YEAR(date_transmission) = ' . $this->annee;
|
|
|
137 |
}
|
|
|
138 |
if ($mpm) {
|
|
|
139 |
$requete = $this->encapsulerMPM($requete, 'date_transmission');
|
|
|
140 |
}
|
|
|
141 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
142 |
return intval(array_pop($resultat[0]));
|
1818 |
jpm |
143 |
}
|
|
|
144 |
|
2016 |
mathias |
145 |
/**
|
|
|
146 |
* Nombre d'obs sans identification (ou tag ou certitude)
|
|
|
147 |
*/
|
|
|
148 |
private function getNbObsSansIdentOuTC($mpm=false) {
|
|
|
149 |
$requete = "SELECT COUNT(id_observation) AS nb_total FROM del_observation WHERE";
|
|
|
150 |
if ($this->annee != null) {
|
|
|
151 |
$requete .= ' YEAR(date_transmission) = ' . $this->annee . " AND";
|
|
|
152 |
}
|
2019 |
mathias |
153 |
$requete .= " (mots_cles_texte LIKE '%determiner%' OR nom_sel_nn = '' OR nom_sel_nn IS NULL OR certitude IN ('aDeterminer','douteux'))";
|
2016 |
mathias |
154 |
if ($mpm) {
|
|
|
155 |
$requete = $this->encapsulerMPM($requete, 'date_transmission');
|
|
|
156 |
}
|
1818 |
jpm |
157 |
$resultat = $this->bdd->recupererTous($requete);
|
2016 |
mathias |
158 |
return intval(array_pop($resultat[0]));
|
1818 |
jpm |
159 |
}
|
|
|
160 |
|
2016 |
mathias |
161 |
/**
|
|
|
162 |
* Nombre d'obs sans identification
|
|
|
163 |
*/
|
|
|
164 |
private function getNbObsSansIdent($mpm=false) {
|
|
|
165 |
$requete = "SELECT COUNT(id_observation) AS nb_total FROM del_observation WHERE";
|
|
|
166 |
if ($this->annee != null) {
|
|
|
167 |
$requete .= ' YEAR(date_transmission) = ' . $this->annee . " AND";
|
|
|
168 |
}
|
2023 |
mathias |
169 |
$requete .= " (nom_sel_nn = '' OR nom_sel_nn IS NULL)";
|
2016 |
mathias |
170 |
if ($mpm) {
|
|
|
171 |
$requete = $this->encapsulerMPM($requete, 'date_transmission');
|
|
|
172 |
}
|
|
|
173 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
174 |
return intval(array_pop($resultat[0]));
|
1818 |
jpm |
175 |
}
|
|
|
176 |
|
2016 |
mathias |
177 |
/**
|
|
|
178 |
* Nombre d'obs avec tag à déterminer ou certitude incertaine
|
|
|
179 |
*/
|
|
|
180 |
private function getNbObsTC($mpm=false) {
|
|
|
181 |
$requete = "SELECT COUNT(id_observation) AS nb_total FROM del_observation WHERE";
|
|
|
182 |
if ($this->annee != null) {
|
|
|
183 |
$requete .= ' YEAR(date_transmission) = ' . $this->annee . " AND";
|
|
|
184 |
}
|
|
|
185 |
$requete .= " (mots_cles_texte LIKE '%determiner%' OR certitude IN ('aDeterminer','douteux'))";
|
|
|
186 |
if ($mpm) {
|
|
|
187 |
$requete = $this->encapsulerMPM($requete, 'date_transmission');
|
|
|
188 |
}
|
1818 |
jpm |
189 |
$resultat = $this->bdd->recupererTous($requete);
|
2016 |
mathias |
190 |
return intval(array_pop($resultat[0]));
|
1818 |
jpm |
191 |
}
|
|
|
192 |
|
2016 |
mathias |
193 |
/**
|
|
|
194 |
* Nombre d'obs avec tag à déterminer ou certitude incertaine et retenue
|
|
|
195 |
*/
|
|
|
196 |
private function getNbObsTCRetenue($mpm=false) {
|
|
|
197 |
$requete = "SELECT COUNT(*) AS nb_total FROM del_commentaire WHERE proposition_retenue = 1 AND ce_observation IN (SELECT id_observation FROM del_observation WHERE";
|
|
|
198 |
if ($this->annee != null) {
|
|
|
199 |
$requete .= ' YEAR(date_transmission) = ' . $this->annee . " AND";
|
|
|
200 |
}
|
|
|
201 |
$requete .= " (certitude IN ('aDeterminer','douteux')))";
|
|
|
202 |
if ($mpm) {
|
2017 |
mathias |
203 |
// @TODO vérifier que grouper sur "date" est pertinent
|
|
|
204 |
// date_transmission n'est pas dispo pour grouper ici :-/
|
|
|
205 |
$requete = $this->encapsulerMPM($requete);
|
2016 |
mathias |
206 |
}
|
1818 |
jpm |
207 |
$resultat = $this->bdd->recupererTous($requete);
|
2016 |
mathias |
208 |
return intval(array_pop($resultat[0]));
|
1818 |
jpm |
209 |
}
|
|
|
210 |
|
2016 |
mathias |
211 |
/**
|
|
|
212 |
* Nombre d'obs avec tag à déterminer ou certitude incertaine et avec consensus
|
|
|
213 |
*/
|
|
|
214 |
private function getNbObsTCConsensus($mpm=false) {
|
|
|
215 |
$requete = "SELECT COUNT(id_observation) AS nb_total FROM del_observation WHERE";
|
1818 |
jpm |
216 |
if ($this->annee != null) {
|
2016 |
mathias |
217 |
$requete .= ' YEAR(date_transmission) = ' . $this->annee . " AND";
|
1818 |
jpm |
218 |
}
|
2016 |
mathias |
219 |
$requete .= " (mots_cles_texte LIKE '%determiner%' OR certitude IN ('aDeterminer','douteux')) AND id_observation IN"
|
|
|
220 |
. " (SELECT ce_observation FROM del_commentaire WHERE proposition_initiale = 1"
|
|
|
221 |
. " AND nom_sel_nn != 0"
|
|
|
222 |
. " AND nom_sel_nn IS NOT NULL"
|
|
|
223 |
. " AND id_commentaire IN (SELECT ce_proposition FROM del_commentaire_vote dcv";
|
|
|
224 |
if ($this->annee != null) {
|
|
|
225 |
$requete .= ' WHERE YEAR(date) <= ' . $this->annee;
|
|
|
226 |
}
|
|
|
227 |
$requete .= " GROUP BY ce_proposition HAVING SUM(CASE"
|
|
|
228 |
. " WHEN valeur = 1 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' != 0 THEN 3"
|
|
|
229 |
. " WHEN valeur = 0 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' != 0 THEN -3"
|
|
|
230 |
. " WHEN valeur = 1 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' = 0 THEN 1"
|
|
|
231 |
. " WHEN valeur = 0 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' = 0 THEN -1"
|
|
|
232 |
. " END) >= 4))";
|
|
|
233 |
if ($mpm) {
|
|
|
234 |
$requete = $this->encapsulerMPM($requete, 'date_transmission');
|
|
|
235 |
}
|
1818 |
jpm |
236 |
$resultat = $this->bdd->recupererTous($requete);
|
2016 |
mathias |
237 |
return intval(array_pop($resultat[0]));
|
1818 |
jpm |
238 |
}
|
|
|
239 |
|
2016 |
mathias |
240 |
/**
|
|
|
241 |
* Nombre d'obs avec tag à déterminer ou certitude incertaine et avec consensus mais non validées
|
|
|
242 |
*/
|
|
|
243 |
private function getNbObsTCConsensusNonValide($mpm=false) {
|
|
|
244 |
$requete = "SELECT COUNT(id_observation) AS nb_total FROM del_observation WHERE";
|
|
|
245 |
if ($this->annee != null) {
|
|
|
246 |
$requete .= ' YEAR(date_transmission) = ' . $this->annee . " AND";
|
|
|
247 |
}
|
|
|
248 |
$requete .= " (mots_cles_texte LIKE '%determiner%' OR certitude IN ('aDeterminer','douteux')) AND id_observation IN"
|
|
|
249 |
. " (SELECT ce_observation FROM del_commentaire WHERE proposition_initiale = 1 AND proposition_retenue = 0"
|
|
|
250 |
. " AND nom_sel_nn != 0"
|
|
|
251 |
. " AND nom_sel_nn IS NOT NULL"
|
|
|
252 |
. " AND id_commentaire IN (SELECT ce_proposition FROM del_commentaire_vote dcv";
|
|
|
253 |
if ($this->annee != null) {
|
|
|
254 |
$requete .= ' WHERE YEAR(date) <= ' . $this->annee;
|
|
|
255 |
}
|
|
|
256 |
$requete .= " GROUP BY ce_proposition HAVING SUM(CASE"
|
|
|
257 |
. " WHEN valeur = 1 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' != 0 THEN 3"
|
|
|
258 |
. " WHEN valeur = 0 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' != 0 THEN -3"
|
|
|
259 |
. " WHEN valeur = 1 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' = 0 THEN 1"
|
|
|
260 |
. " WHEN valeur = 0 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' = 0 THEN -1"
|
|
|
261 |
. " END) >= 4))";
|
|
|
262 |
if ($mpm) {
|
|
|
263 |
$requete = $this->encapsulerMPM($requete, 'date_transmission');
|
|
|
264 |
}
|
1818 |
jpm |
265 |
$resultat = $this->bdd->recupererTous($requete);
|
2016 |
mathias |
266 |
return intval(array_pop($resultat[0]));
|
1818 |
jpm |
267 |
}
|
2011 |
mathias |
268 |
|
|
|
269 |
/**
|
2013 |
mathias |
270 |
* Statistiques sur les propositions, les commentaires et les votes
|
|
|
271 |
* "MPM" = moyenne par mois
|
|
|
272 |
* - Nombre de votes
|
|
|
273 |
* - Nombre de commentaires
|
|
|
274 |
* - Nombre d'actions par jour
|
|
|
275 |
* - Nombres de propositions sur toutes les obs
|
2020 |
mathias |
276 |
* - Nombre d'observations ayant une proposition retenue (parmi toutes les observations)
|
|
|
277 |
* - Nombre d'observations ayant une proposition retenue ou en consensus (parmi toutes les observations)
|
|
|
278 |
* - Nombre de propositions sur les obs d'une année
|
2011 |
mathias |
279 |
*/
|
|
|
280 |
private function getPropositions() {
|
|
|
281 |
return array(
|
2013 |
mathias |
282 |
'nbVotes' => $this->getNbVotes(),
|
|
|
283 |
'nbVotesMPM' => $this->getNbVotes(true),
|
|
|
284 |
'nbMoyenActionsParJour' => $this->getNbMoyenActionsParJour(),
|
|
|
285 |
'nbCommentaires' => $this->getNbCommentaires(),
|
|
|
286 |
'nbCommentairesMPM' => $this->getNbCommentaires(true),
|
|
|
287 |
'nbPropositionsToutesObs' => $this->getNbPropositionsToutesObs(),
|
|
|
288 |
'nbPropositionsToutesObsMPM' => $this->getNbPropositionsToutesObs(true),
|
|
|
289 |
'nbPropositionsRetenuesToutesObs' => $this->getNbPropositionsRetenuesToutesObs(),
|
|
|
290 |
'nbPropositionsRetenuesToutesObsMPM' => $this->getNbPropositionsRetenuesToutesObs(true),
|
2016 |
mathias |
291 |
'nbPropositionsConsensusToutesObs' => $this->getNbPropositionsConsensusToutesObs(),
|
|
|
292 |
'nbPropositionsConsensusToutesObsMPM' => $this->getNbPropositionsConsensusToutesObs(true),
|
2013 |
mathias |
293 |
'nbPropositionsObsAnnee' => $this->getNbPropositionsObsAnnee(),
|
|
|
294 |
'nbPropositionsObsAnneeMPM' => $this->getNbPropositionsObsAnnee(true),
|
2011 |
mathias |
295 |
);
|
|
|
296 |
}
|
|
|
297 |
|
|
|
298 |
/**
|
2013 |
mathias |
299 |
* Nombre moyen d'actions par jour (commentaire, proposition, vote)
|
2011 |
mathias |
300 |
*/
|
2013 |
mathias |
301 |
private function getNbMoyenActionsParJour() {
|
|
|
302 |
$requete = "SELECT (SELECT (SELECT count(*) FROM del_commentaire";
|
|
|
303 |
if ($this->annee != null) {
|
|
|
304 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
305 |
}
|
|
|
306 |
$requete .= ") + (SELECT count(*) FROM del_commentaire_vote";
|
|
|
307 |
if ($this->annee != null) {
|
|
|
308 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
309 |
}
|
|
|
310 |
$requete .= ") + (SELECT count(*) FROM del_commentaire";
|
|
|
311 |
if ($this->annee != null) {
|
|
|
312 |
$requete .= ' WHERE YEAR(date_validation) = ' . $this->annee;
|
|
|
313 |
}
|
|
|
314 |
$requete .= ")) / (";
|
|
|
315 |
if ($this->annee != null) {
|
|
|
316 |
$requete .= "SELECT IF( YEAR(CURDATE()) = " . $this->annee . ", DAYOFYEAR(CURDATE()), 365) ";
|
|
|
317 |
} else {
|
|
|
318 |
$requete .= "365";
|
|
|
319 |
}
|
|
|
320 |
$requete .= ")";
|
2011 |
mathias |
321 |
$resultat = $this->bdd->recupererTous($requete);
|
2013 |
mathias |
322 |
return intval(array_pop($resultat[0]));
|
2011 |
mathias |
323 |
}
|
|
|
324 |
|
|
|
325 |
/**
|
2020 |
mathias |
326 |
* Nombre de propositions faites sur toutes les observations (hors initiales)
|
2011 |
mathias |
327 |
*/
|
2013 |
mathias |
328 |
private function getNbPropositionsToutesObs($mpm=false) {
|
2019 |
mathias |
329 |
$requete = "SELECT COUNT(DISTINCT id_commentaire) AS nb_total FROM del_commentaire WHERE";
|
2013 |
mathias |
330 |
if ($this->annee != null) {
|
|
|
331 |
$requete .= ' YEAR(date) = ' . $this->annee . " AND";
|
|
|
332 |
}
|
2019 |
mathias |
333 |
$requete .= " (nom_sel_nn IS NOT NULL OR nom_sel_nn != '') AND proposition_initiale = 0";
|
2013 |
mathias |
334 |
if ($mpm) {
|
|
|
335 |
$requete = $this->encapsulerMPM($requete);
|
|
|
336 |
}
|
|
|
337 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
338 |
return intval(array_pop($resultat[0]));
|
|
|
339 |
}
|
|
|
340 |
|
|
|
341 |
/**
|
2020 |
mathias |
342 |
* Nombre d'observations ayant une proposition retenue (parmi toutes les observations)
|
2013 |
mathias |
343 |
*/
|
|
|
344 |
private function getNbPropositionsRetenuesToutesObs($mpm=false) {
|
2020 |
mathias |
345 |
$requete = "SELECT COUNT(DISTINCT ce_observation) AS nb_total FROM del_commentaire WHERE";
|
2013 |
mathias |
346 |
if ($this->annee != null) {
|
|
|
347 |
$requete .= ' YEAR(date) = ' . $this->annee . " AND";
|
|
|
348 |
}
|
|
|
349 |
$requete .= " proposition_retenue = 1";
|
|
|
350 |
if ($mpm) {
|
|
|
351 |
$requete = $this->encapsulerMPM($requete);
|
|
|
352 |
}
|
|
|
353 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
354 |
return intval(array_pop($resultat[0]));
|
|
|
355 |
}
|
|
|
356 |
|
|
|
357 |
/**
|
2020 |
mathias |
358 |
* Nombre d'observations ayant une proposition retenue ou en consensus (parmi toutes les observations)
|
2013 |
mathias |
359 |
*/
|
|
|
360 |
private function getNbPropositionsConsensusToutesObs($mpm=false) {
|
2016 |
mathias |
361 |
$requete = "SELECT COUNT(DISTINCT ce_observation) AS nb_total FROM del_commentaire dc WHERE"
|
|
|
362 |
. " dc.proposition_retenue = 1"
|
|
|
363 |
. " OR (dc.proposition_initiale = 1"
|
|
|
364 |
. " AND dc.nom_sel_nn != 0"
|
|
|
365 |
. " AND dc.nom_sel_nn IS NOT NULL"
|
|
|
366 |
. " AND dc.id_commentaire IN"
|
|
|
367 |
. " (SELECT ce_proposition FROM del_commentaire_vote dcv WHERE";
|
|
|
368 |
if ($this->annee != null) {
|
|
|
369 |
$requete .= " year(date) < " . $this->annee . " AND";
|
|
|
370 |
}
|
|
|
371 |
$requete .= " ce_proposition NOT IN (SELECT ce_proposition FROM del_commentaire_vote dcv";
|
|
|
372 |
if ($this->annee != null) {
|
|
|
373 |
$requete .= " WHERE year(date) < " . ($this->annee - 1);
|
|
|
374 |
}
|
|
|
375 |
$requete .= " GROUP BY ce_proposition"
|
|
|
376 |
. " HAVING SUM(CASE"
|
|
|
377 |
. " WHEN valeur = 1 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' != 0 THEN 3"
|
|
|
378 |
. " WHEN valeur = 0 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' != 0 THEN -3"
|
|
|
379 |
. " WHEN valeur = 1 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' = 0 THEN 1"
|
|
|
380 |
. " WHEN valeur = 0 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' = 0 THEN -1"
|
|
|
381 |
. " END) >= 4)"
|
|
|
382 |
. " GROUP BY ce_proposition"
|
|
|
383 |
. " HAVING SUM(CASE"
|
|
|
384 |
. " WHEN valeur = 1 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' != 0 THEN 3"
|
|
|
385 |
. " WHEN valeur = 0 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' != 0 THEN -3"
|
|
|
386 |
. " WHEN valeur = 1 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' = 0 THEN 1"
|
|
|
387 |
. " WHEN valeur = 0 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' = 0 THEN -1"
|
|
|
388 |
. " END) >= 4"
|
|
|
389 |
. " )"
|
|
|
390 |
. " )";
|
|
|
391 |
if ($mpm) {
|
|
|
392 |
$requete = $this->encapsulerMPM($requete);
|
|
|
393 |
}
|
2011 |
mathias |
394 |
$resultat = $this->bdd->recupererTous($requete);
|
2016 |
mathias |
395 |
return intval(array_pop($resultat[0]));
|
2011 |
mathias |
396 |
}
|
|
|
397 |
|
|
|
398 |
/**
|
2020 |
mathias |
399 |
* Nombre d'observations ayant une proposition retenue (parmi les observations de l'année)
|
2011 |
mathias |
400 |
*/
|
2013 |
mathias |
401 |
private function getNbPropositionsObsAnnee($mpm=false) {
|
|
|
402 |
if ($this->annee == null) {
|
|
|
403 |
return null;
|
|
|
404 |
}
|
2020 |
mathias |
405 |
$requete = "SELECT COUNT(DISTINCT ce_observation) AS nb_total FROM del_commentaire WHERE YEAR(date) = " . $this->annee . " AND "
|
2019 |
mathias |
406 |
. "(nom_sel_nn IS NOT NULL OR nom_sel_nn != '') AND proposition_initiale = 0 AND ce_observation in"
|
|
|
407 |
. " (SELECT id_observation FROM del_observation WHERE year(date_transmission) = " . $this->annee . ")";
|
2013 |
mathias |
408 |
if ($mpm) {
|
|
|
409 |
$requete = $this->encapsulerMPM($requete);
|
|
|
410 |
}
|
|
|
411 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
412 |
return intval(array_pop($resultat[0]));
|
|
|
413 |
}
|
|
|
414 |
|
|
|
415 |
/**
|
2020 |
mathias |
416 |
* Nombre d'observations ayant une proposition retenue ou en consensus (parmi les observations de l'année)
|
2013 |
mathias |
417 |
*/
|
|
|
418 |
private function getNbPropositionsRetenuesObsAnnee($mpm=false) {
|
2021 |
mathias |
419 |
$requete = "SELECT COUNT(DISTINCT ce_observation) AS nb_total FROM del_commentaire WHERE ";
|
|
|
420 |
if ($this->annee != null) {
|
|
|
421 |
$requete .= "YEAR(date) = " . $this->annee . " AND ";
|
2013 |
mathias |
422 |
}
|
2021 |
mathias |
423 |
$requete .= "proposition_retenue = 1 AND ce_observation in (SELECT id_observation FROM del_observation ";
|
|
|
424 |
if ($this->annee != null) {
|
|
|
425 |
$requete .= "WHERE year(date_transmission) = " . $this->annee;
|
|
|
426 |
}
|
|
|
427 |
$requete .= ")";
|
2013 |
mathias |
428 |
if ($mpm) {
|
|
|
429 |
$requete = $this->encapsulerMPM($requete);
|
|
|
430 |
}
|
|
|
431 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
432 |
return intval(array_pop($resultat[0]));
|
|
|
433 |
}
|
|
|
434 |
|
|
|
435 |
/**
|
2016 |
mathias |
436 |
* Nombre de proposition en consensus faites sur les observations d'une année
|
2013 |
mathias |
437 |
*/
|
|
|
438 |
private function getNbPropositionsConsensusObsAnnee($mpm=false) {
|
2021 |
mathias |
439 |
$requete = "SELECT COUNT(DISTINCT ce_observation) AS nb_total FROM del_commentaire dc WHERE ce_observation in ("
|
|
|
440 |
. " SELECT id_observation FROM del_observation ";
|
|
|
441 |
if ($this->annee != null) {
|
|
|
442 |
$requete .= "WHERE year(date_transmission) = " . $this->annee ;
|
2016 |
mathias |
443 |
}
|
2021 |
mathias |
444 |
$requete .= ") AND ("
|
2016 |
mathias |
445 |
. " dc.proposition_retenue = 1 OR (dc.proposition_initiale = 1"
|
|
|
446 |
. " AND dc.nom_sel_nn != 0 AND dc.nom_sel_nn IS NOT NULL AND dc.id_commentaire IN"
|
2021 |
mathias |
447 |
. " (SELECT ce_proposition FROM del_commentaire_vote dcv";
|
|
|
448 |
if ($this->annee != null) {
|
|
|
449 |
$requete .= " WHERE year(date) <= " . $this->annee;
|
|
|
450 |
}
|
|
|
451 |
$requete .= " GROUP BY ce_proposition"
|
2016 |
mathias |
452 |
. " HAVING SUM(CASE"
|
|
|
453 |
. " WHEN valeur = 1 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' != 0 THEN 3"
|
|
|
454 |
. " WHEN valeur = 0 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' != 0 THEN -3"
|
|
|
455 |
. " WHEN valeur = 1 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' = 0 THEN 1"
|
|
|
456 |
. " WHEN valeur = 0 AND dcv.ce_utilisateur REGEXP '^-?[0-9]+$' = 0 THEN -1"
|
|
|
457 |
. " END) >= 4)"
|
|
|
458 |
. "))";
|
|
|
459 |
if ($mpm) {
|
|
|
460 |
$requete = $this->encapsulerMPM($requete);
|
|
|
461 |
}
|
2011 |
mathias |
462 |
$resultat = $this->bdd->recupererTous($requete);
|
2016 |
mathias |
463 |
return intval(array_pop($resultat[0]));
|
2011 |
mathias |
464 |
}
|
|
|
465 |
|
|
|
466 |
/**
|
2013 |
mathias |
467 |
* Nombre de votes
|
|
|
468 |
*/
|
|
|
469 |
private function getNbVotes($mpm=false) {
|
2019 |
mathias |
470 |
$requete = "SELECT COUNT(DISTINCT id_vote) AS nb_total FROM del_commentaire_vote";
|
2013 |
mathias |
471 |
if ($this->annee != null) {
|
|
|
472 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
473 |
}
|
|
|
474 |
if ($mpm) {
|
|
|
475 |
$requete = $this->encapsulerMPM($requete);
|
|
|
476 |
}
|
|
|
477 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
478 |
return intval(array_pop($resultat[0]));
|
|
|
479 |
}
|
|
|
480 |
|
|
|
481 |
/**
|
|
|
482 |
* Nombre de commentaires
|
|
|
483 |
*/
|
|
|
484 |
private function getNbCommentaires($mpm=false) {
|
2019 |
mathias |
485 |
$requete = "SELECT COUNT(DISTINCT id_commentaire) AS nb_total FROM del_commentaire WHERE ce_proposition != '' AND (nom_sel IS NULL OR nom_sel = '')";
|
2013 |
mathias |
486 |
if ($this->annee != null) {
|
|
|
487 |
$requete .= ' AND YEAR(date) = ' . $this->annee;
|
|
|
488 |
}
|
|
|
489 |
if ($mpm) {
|
|
|
490 |
$requete = $this->encapsulerMPM($requete);
|
|
|
491 |
}
|
|
|
492 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
493 |
return intval(array_pop($resultat[0]));
|
|
|
494 |
}
|
|
|
495 |
|
|
|
496 |
/**
|
2011 |
mathias |
497 |
* Statistiques sur les utilisateurs d'Identiplante
|
2013 |
mathias |
498 |
* "AF" = ayant fait un(e)
|
|
|
499 |
* "MPM" = moyenne par mois
|
2011 |
mathias |
500 |
* - Nombre total d'utilisateurs
|
2013 |
mathias |
501 |
* - Nombre d'utilisateurs ayant fait une proposition
|
2016 |
mathias |
502 |
* - Nombre d'utilisateurs identifiés ayant fait un vote
|
|
|
503 |
* - Nombre d'utilisateurs anonymes ayant fait un vote
|
2013 |
mathias |
504 |
* - Nombre d'utilisateurs ayant fait un commentaire
|
2016 |
mathias |
505 |
* - Nombre d'utilisateurs ayant fait une action
|
2011 |
mathias |
506 |
*/
|
|
|
507 |
private function getUtilisateursIp() {
|
|
|
508 |
return array(
|
|
|
509 |
'nbUtilisateursTotal' => $this->getNbUtilisateursIpTotal(),
|
2013 |
mathias |
510 |
'nbUtilisateursAFProposition' => $this->getNbUtilisateursAFProposition(),
|
|
|
511 |
'nbUtilisateursAFCommentaire' => $this->getNbUtilisateursAFCommentaire(),
|
|
|
512 |
'nbUtilisateursAFVote' => $this->getNbUtilisateursAFVote(),
|
|
|
513 |
'nbUtilisateursAnonymesAFVote' => $this->getNbUtilisateursAnonymesAFVote(),
|
2016 |
mathias |
514 |
'nbUtilisateursAFAction' => $this->getNbUtilisateursAFAction(),
|
2013 |
mathias |
515 |
'nbUtilisateursAFPropositionMPM' => $this->getNbUtilisateursAFProposition(true),
|
|
|
516 |
'nbUtilisateursAFCommentaireMPM' => $this->getNbUtilisateursAFCommentaire(true),
|
|
|
517 |
'nbUtilisateursAFVoteMPM' => $this->getNbUtilisateursAFVote(true),
|
|
|
518 |
'nbUtilisateursAnonymesAFVoteMPM' => $this->getNbUtilisateursAnonymesAFVote(true),
|
2016 |
mathias |
519 |
'nbUtilisateursAFActionMPM' => $this->getNbUtilisateursAFActionMPM()
|
2011 |
mathias |
520 |
);
|
|
|
521 |
}
|
|
|
522 |
|
|
|
523 |
/**
|
2013 |
mathias |
524 |
* Nombre total d'utilisateurs d'Identiplante
|
2011 |
mathias |
525 |
*/
|
|
|
526 |
private function getNbUtilisateursIpTotal() {
|
2013 |
mathias |
527 |
$requete = "SELECT COUNT(DISTINCT ce_utilisateur) AS nb_total FROM del_commentaire";
|
|
|
528 |
if ($this->annee != null) {
|
|
|
529 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
530 |
}
|
2011 |
mathias |
531 |
$resultat = $this->bdd->recupererTous($requete);
|
2013 |
mathias |
532 |
return intval(array_pop($resultat[0]));
|
2011 |
mathias |
533 |
}
|
|
|
534 |
|
|
|
535 |
/**
|
2013 |
mathias |
536 |
* Nombre d'utilisateurs d'Identiplante ayant fait au moins une proposition
|
2011 |
mathias |
537 |
*/
|
2013 |
mathias |
538 |
private function getNbUtilisateursAFProposition($mpm=false) {
|
2019 |
mathias |
539 |
$requete = "SELECT COUNT(DISTINCT utilisateur_courriel) AS nb_total FROM del_commentaire WHERE ce_proposition = '' AND nom_sel IS NOT NULL AND nom_sel != ''";
|
2013 |
mathias |
540 |
if ($this->annee != null) {
|
|
|
541 |
$requete .= ' AND YEAR(date) = ' . $this->annee;
|
|
|
542 |
}
|
|
|
543 |
if ($mpm) {
|
|
|
544 |
$requete = $this->encapsulerMPM($requete);
|
|
|
545 |
}
|
2011 |
mathias |
546 |
$resultat = $this->bdd->recupererTous($requete);
|
2013 |
mathias |
547 |
return intval(array_pop($resultat[0]));
|
2011 |
mathias |
548 |
}
|
|
|
549 |
|
|
|
550 |
/**
|
2013 |
mathias |
551 |
* Nombre d'utilisateurs d'Identiplante ayant fait au moins un commentaire
|
2011 |
mathias |
552 |
*/
|
2013 |
mathias |
553 |
private function getNbUtilisateursAFCommentaire($mpm=false) {
|
2019 |
mathias |
554 |
$requete = "SELECT COUNT(DISTINCT utilisateur_courriel) AS nb_total FROM del_commentaire WHERE ce_proposition != '' AND (nom_sel IS NULL OR nom_sel = '')";
|
2013 |
mathias |
555 |
if ($this->annee != null) {
|
|
|
556 |
$requete .= ' AND YEAR(date) = ' . $this->annee;
|
|
|
557 |
}
|
|
|
558 |
if ($mpm) {
|
|
|
559 |
$requete = $this->encapsulerMPM($requete);
|
|
|
560 |
}
|
2011 |
mathias |
561 |
$resultat = $this->bdd->recupererTous($requete);
|
2013 |
mathias |
562 |
return intval(array_pop($resultat[0]));
|
2011 |
mathias |
563 |
}
|
|
|
564 |
|
|
|
565 |
/**
|
2013 |
mathias |
566 |
* Nombre d'utilisateurs d'Identiplante identifiés prenant part aux votes
|
2011 |
mathias |
567 |
*/
|
2013 |
mathias |
568 |
private function getNbUtilisateursAFVote($mpm=false) {
|
|
|
569 |
$requete = "SELECT COUNT(DISTINCT ce_utilisateur) AS nb_total FROM del_commentaire_vote WHERE ce_utilisateur REGEXP '^-?[0-9]+$'";
|
|
|
570 |
if ($this->annee != null) {
|
|
|
571 |
$requete .= ' AND YEAR(date) = ' . $this->annee;
|
|
|
572 |
}
|
|
|
573 |
if ($mpm) {
|
|
|
574 |
$requete = $this->encapsulerMPM($requete);
|
|
|
575 |
}
|
2011 |
mathias |
576 |
$resultat = $this->bdd->recupererTous($requete);
|
2013 |
mathias |
577 |
return intval(array_pop($resultat[0]));
|
2011 |
mathias |
578 |
}
|
|
|
579 |
|
|
|
580 |
/**
|
2013 |
mathias |
581 |
* Nombre d'utilisateurs d'Identiplante anonymes prenant part aux votes
|
2011 |
mathias |
582 |
*/
|
2013 |
mathias |
583 |
private function getNbUtilisateursAnonymesAFVote($mpm=false) {
|
|
|
584 |
$requete = "SELECT COUNT(DISTINCT ce_utilisateur) AS nb_total FROM del_commentaire_vote WHERE ce_utilisateur NOT REGEXP '^-?[0-9]+$'";
|
|
|
585 |
if ($this->annee != null) {
|
|
|
586 |
$requete .= ' AND YEAR(date) = ' . $this->annee;
|
|
|
587 |
}
|
|
|
588 |
if ($mpm) {
|
|
|
589 |
$requete = $this->encapsulerMPM($requete);
|
|
|
590 |
}
|
|
|
591 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
592 |
return intval(array_pop($resultat[0]));
|
|
|
593 |
}
|
|
|
594 |
|
|
|
595 |
/**
|
2016 |
mathias |
596 |
* Nombre d'utilisateurs d'Identiplante ayant fait une action (commentaire, vote, proposition)
|
|
|
597 |
*/
|
|
|
598 |
private function getNbUtilisateursAFAction() {
|
|
|
599 |
$requete = "SELECT COUNT(*) AS nb_total FROM (SELECT ce_utilisateur FROM del_commentaire_vote";
|
|
|
600 |
if ($this->annee != null) {
|
|
|
601 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
602 |
}
|
|
|
603 |
$requete .= " UNION SELECT ce_utilisateur FROM del_commentaire";
|
|
|
604 |
if ($this->annee != null) {
|
|
|
605 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
606 |
}
|
|
|
607 |
$requete .= " ) AS action";
|
|
|
608 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
609 |
return intval(array_pop($resultat[0]));
|
|
|
610 |
}
|
|
|
611 |
|
|
|
612 |
/**
|
|
|
613 |
* Moyenne par mois du nombre d'utilisateurs d'Identiplante ayant fait une action
|
|
|
614 |
* (commentaire, vote, proposition) -> n'est pas encapsulable par encapsulerMPM()
|
|
|
615 |
*/
|
|
|
616 |
private function getNbUtilisateursAFActionMPM() {
|
|
|
617 |
$requete = "SELECT avg(nb_total) FROM (SELECT count(*) as nb_total FROM"
|
|
|
618 |
. " (SELECT * FROM (SELECT ce_utilisateur, date FROM del_commentaire_vote";
|
|
|
619 |
if ($this->annee != null) {
|
|
|
620 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
621 |
}
|
|
|
622 |
$requete .= " UNION SELECT ce_utilisateur, date FROM del_commentaire";
|
|
|
623 |
if ($this->annee != null) {
|
|
|
624 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
625 |
}
|
|
|
626 |
$requete .= " ) AS action GROUP BY ce_utilisateur) AS utildate GROUP BY CONCAT(year(date),month(date))) as truc";
|
|
|
627 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
628 |
return intval(array_pop($resultat[0]));
|
|
|
629 |
}
|
|
|
630 |
|
|
|
631 |
/**
|
2013 |
mathias |
632 |
* Liste des utilisateurs dont les propositions ont été votées positivement
|
|
|
633 |
*/
|
2011 |
mathias |
634 |
private function getListeMeilleursProposeurs() {
|
|
|
635 |
$liste = array();
|
2018 |
mathias |
636 |
$requete = "SELECT * FROM (SELECT utilisateur_courriel, ce_utilisateur, count(prop) as nb_prop"
|
2019 |
mathias |
637 |
. " FROM (SELECT ce_proposition as prop, COUNT(DISTINCT id_vote) AS nb_vote FROM del_commentaire_vote where";
|
2013 |
mathias |
638 |
if ($this->annee != null) {
|
2019 |
mathias |
639 |
$requete .= " year(date) = " . $this->annee . " AND";
|
2013 |
mathias |
640 |
}
|
2019 |
mathias |
641 |
$requete .= " valeur = 1 GROUP BY ce_proposition) AS vote, del_commentaire WHERE nb_vote > 3 AND prop = id_commentaire AND ce_utilisateur != 0 GROUP BY ce_utilisateur)"
|
2013 |
mathias |
642 |
. " AS utlisateurs WHERE nb_prop > 10 ORDER BY nb_prop DESC LIMIT 20";
|
2011 |
mathias |
643 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
644 |
|
2018 |
mathias |
645 |
// Formatage de la liste avec les intitulés des utilisateurs
|
|
|
646 |
$ids = array_column($resultat, 'ce_utilisateur');
|
|
|
647 |
$ids = array_filter($ids, 'is_numeric'); // on oublie les ids de session et autres facéties
|
|
|
648 |
$infosUtilisateurs = $this->recupererIntitulesUtilisateursParIds($ids, true);
|
|
|
649 |
foreach ($resultat as &$util) {
|
|
|
650 |
$ce = $util['ce_utilisateur'];
|
|
|
651 |
$util['intitule'] = isset($infosUtilisateurs[$ce]['intitule']) ? $infosUtilisateurs[$ce]['intitule'] : null;
|
|
|
652 |
}
|
|
|
653 |
|
2011 |
mathias |
654 |
return array(
|
2013 |
mathias |
655 |
'liste' => $resultat
|
2011 |
mathias |
656 |
);
|
|
|
657 |
}
|
|
|
658 |
|
|
|
659 |
/**
|
2013 |
mathias |
660 |
* Liste des utilisateurs ayant fait le plus de votes positifs
|
|
|
661 |
* @TODO et le plus de votes sur des propositions retenues (ou ayant atteint un consensus)
|
2011 |
mathias |
662 |
*/
|
|
|
663 |
private function getListeMeilleursVoteurs() {
|
|
|
664 |
$liste = array();
|
2019 |
mathias |
665 |
$requete = "SELECT * FROM (SELECT courriel, ce_utilisateur, COUNT(DISTINCT id_vote) AS nombre FROM del_commentaire_vote, del_utilisateur where";
|
2013 |
mathias |
666 |
if ($this->annee != null) {
|
2019 |
mathias |
667 |
$requete .= " year(date) = " . $this->annee . " AND";
|
2013 |
mathias |
668 |
}
|
2019 |
mathias |
669 |
$requete .= " ce_utilisateur = id_utilisateur AND valeur = 1 GROUP BY ce_utilisateur) AS utilisateurs WHERE nombre > 100 ORDER BY nombre DESC LIMIT 20";
|
2011 |
mathias |
670 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
671 |
|
2018 |
mathias |
672 |
// Formatage de la liste avec les intitulés des utilisateurs
|
|
|
673 |
$ids = array_column($resultat, 'ce_utilisateur');
|
|
|
674 |
$ids = array_filter($ids, 'is_numeric'); // on oublie les ids de session et autres facéties
|
|
|
675 |
$infosUtilisateurs = $this->recupererIntitulesUtilisateursParIds($ids, true);
|
|
|
676 |
foreach ($resultat as &$util) {
|
|
|
677 |
$ce = $util['ce_utilisateur'];
|
|
|
678 |
$util['intitule'] = isset($infosUtilisateurs[$ce]['intitule']) ? $infosUtilisateurs[$ce]['intitule'] : null;
|
|
|
679 |
}
|
|
|
680 |
|
2011 |
mathias |
681 |
return array(
|
2013 |
mathias |
682 |
'liste' => $resultat
|
2011 |
mathias |
683 |
);
|
|
|
684 |
}
|
|
|
685 |
|
|
|
686 |
/**
|
2013 |
mathias |
687 |
* Liste des utilisateurs ayant fait au moins une proposition par mois toute l'année
|
|
|
688 |
*/
|
|
|
689 |
private function getListeProposeursReguliers() {
|
|
|
690 |
$liste = array();
|
|
|
691 |
$requete = "SELECT cal.nbmois, SUM(somme) / cal.nbmois as moyenne, ce_utilisateur, utilisateur_courriel FROM (SELECT count(*) as somme,"
|
|
|
692 |
. " CONCAT(YEAR(date),'-',MONTH(date)) as anneemois, ce_utilisateur, utilisateur_courriel, id_commentaire FROM del_commentaire"
|
|
|
693 |
. " WHERE ce_proposition = '' AND nom_sel_nn != '' AND nom_sel_nn IS NOT NULL";
|
|
|
694 |
if ($this->annee != null) {
|
2019 |
mathias |
695 |
$requete .= " AND year(date) = " . $this->annee;
|
2013 |
mathias |
696 |
}
|
|
|
697 |
$requete .= " GROUP BY anneemois, ce_utilisateur, utilisateur_courriel) as ppm, (SELECT count(distinct CONCAT(YEAR(date),'-',MONTH(date))) as nbmois FROM del_commentaire WHERE";
|
|
|
698 |
if ($this->annee != null) {
|
2019 |
mathias |
699 |
$requete .= " year(date) = " . $this->annee . " AND";
|
2013 |
mathias |
700 |
}
|
|
|
701 |
$requete .= " ce_proposition = '' AND nom_sel_nn != '' AND nom_sel_nn IS NOT NULL) as cal GROUP BY ce_utilisateur, utilisateur_courriel HAVING SUM(somme) / cal.nbmois >= 1"
|
|
|
702 |
. " ORDER BY moyenne DESC"; // @ TODO limite ?
|
|
|
703 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
704 |
|
2018 |
mathias |
705 |
// Formatage de la liste avec les intitulés des utilisateurs
|
|
|
706 |
$ids = array_column($resultat, 'ce_utilisateur');
|
|
|
707 |
$ids = array_filter($ids, 'is_numeric'); // on oublie les ids de session et autres facéties
|
|
|
708 |
$infosUtilisateurs = $this->recupererIntitulesUtilisateursParIds($ids, true);
|
|
|
709 |
foreach ($resultat as &$util) {
|
|
|
710 |
$ce = $util['ce_utilisateur'];
|
|
|
711 |
$util['intitule'] = isset($infosUtilisateurs[$ce]['intitule']) ? $infosUtilisateurs[$ce]['intitule'] : null;
|
|
|
712 |
}
|
|
|
713 |
|
2013 |
mathias |
714 |
return array(
|
|
|
715 |
'liste' => $resultat
|
|
|
716 |
);
|
|
|
717 |
}
|
|
|
718 |
|
|
|
719 |
/**
|
2017 |
mathias |
720 |
* Statistiques sur Sauvages de ma Rue (Sdmr)
|
|
|
721 |
* "MPM" = moyenne par mois
|
|
|
722 |
* - Nombre total d'observations sdmr
|
|
|
723 |
* - Nombre d'observations Sauvages de PACA
|
2011 |
mathias |
724 |
*/
|
2017 |
mathias |
725 |
private function getSdmr() {
|
|
|
726 |
return array(
|
|
|
727 |
'nbObsSdmrTotal' => $this->getNbObsSdmrTotal(),
|
|
|
728 |
'nbObsSdmrTotalMPM' => $this->getNbObsSdmrTotal(true),
|
|
|
729 |
'nbObsSdmrPACA' => $this->getNbObsSdmrPACA(),
|
|
|
730 |
'nbObsSdmrPACAMPM' => $this->getNbObsSdmrPACA(true)
|
|
|
731 |
);
|
|
|
732 |
}
|
|
|
733 |
|
|
|
734 |
/**
|
|
|
735 |
* Nombre total d'observations Sauvages de ma Rue
|
|
|
736 |
*/
|
|
|
737 |
private function getNbObsSdmrTotal($mpm=false) {
|
|
|
738 |
$requete = "SELECT COUNT(DISTINCT ce_observation) as nb_total FROM del_commentaire WHERE";
|
|
|
739 |
if ($this->annee != null) {
|
|
|
740 |
$requete .= ' YEAR(date) <= ' . $this->annee . ' AND';
|
|
|
741 |
}
|
|
|
742 |
$requete .= " ce_observation in (SELECT id_observation FROM del_observation WHERE mots_cles_texte like '%sauvages%')";
|
|
|
743 |
if ($mpm) {
|
|
|
744 |
$requete = $this->encapsulerMPM($requete);
|
|
|
745 |
}
|
|
|
746 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
747 |
return intval(array_pop($resultat[0]));
|
|
|
748 |
}
|
|
|
749 |
|
|
|
750 |
/**
|
|
|
751 |
* Nombre total d'observations Sauvages de ma Rue en PACA
|
|
|
752 |
*/
|
|
|
753 |
private function getNbObsSdmrPACA($mpm=false) {
|
|
|
754 |
$requete = "SELECT COUNT(DISTINCT ce_observation) as nb_total FROM del_commentaire WHERE";
|
|
|
755 |
if ($this->annee != null) {
|
|
|
756 |
$requete .= ' YEAR(date) <= ' . $this->annee . ' AND';
|
|
|
757 |
}
|
|
|
758 |
$requete .= " ce_observation in (SELECT id_observation FROM del_observation"
|
|
|
759 |
. " WHERE SUBSTR(ce_zone_geo, 9 , 2) IN (13,04,05,06,83,84) AND mots_cles_texte like '%sauvages%')";
|
|
|
760 |
if ($mpm) {
|
|
|
761 |
$requete = $this->encapsulerMPM($requete);
|
|
|
762 |
}
|
|
|
763 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
764 |
return intval(array_pop($resultat[0]));
|
|
|
765 |
}
|
|
|
766 |
|
|
|
767 |
/**
|
|
|
768 |
* Statistiques sur les images de Pictoflora
|
|
|
769 |
* "MPM" = Moyenne par mois
|
|
|
770 |
* - Nombre total d'images
|
|
|
771 |
* - Nombre d'images ayant au moins un mot-clé
|
|
|
772 |
* - Nombre d'images ayant au moins un vote
|
|
|
773 |
* - Nombre d'images de l'année ayant au moins un mot-clé
|
|
|
774 |
* - Nombre d'images de l'année ayant au moins un vote
|
|
|
775 |
*/
|
2011 |
mathias |
776 |
private function getImages() {
|
|
|
777 |
return array(
|
2017 |
mathias |
778 |
'nbImagesTotal' => $this->getNbImagesTotal(),
|
|
|
779 |
'nbImagesTotalMPM' => $this->getNbImagesTotal(true),
|
|
|
780 |
'nbImagesAyantTag' => $this->getNbImagesAyantTag(),
|
|
|
781 |
'nbImagesAyantTagMPM' => $this->getNbImagesAyantTag(true),
|
|
|
782 |
'nbImagesAyantVote' => $this->getNbImagesAyantVote(),
|
|
|
783 |
'nbImagesAyantVoteMPM' => $this->getNbImagesAyantVote(true),
|
|
|
784 |
'nbImagesAnneeAyantTag' => $this->getNbImagesAnneeAyantTag(),
|
|
|
785 |
'nbImagesAnneeAyantTagMPM' => $this->getNbImagesAnneeAyantTag(true),
|
|
|
786 |
'nbImagesAnneeAyantVote' => $this->getNbImagesAnneeAyantVote(),
|
|
|
787 |
'nbImagesAnneeAyantVoteMPM' => $this->getNbImagesAnneeAyantVote(true),
|
2011 |
mathias |
788 |
);
|
|
|
789 |
}
|
|
|
790 |
|
|
|
791 |
/**
|
2017 |
mathias |
792 |
* Nombre total d'images Pictoflora
|
2011 |
mathias |
793 |
*/
|
2017 |
mathias |
794 |
private function getNbImagesTotal($mpm=false) {
|
|
|
795 |
$requete = "SELECT COUNT(*) AS nb_total FROM del_image";
|
|
|
796 |
if ($this->annee != null) {
|
|
|
797 |
$requete .= ' WHERE YEAR(date_transmission) = ' . $this->annee;
|
|
|
798 |
}
|
|
|
799 |
if ($mpm) {
|
|
|
800 |
$requete = $this->encapsulerMPM($requete, 'date_transmission');
|
|
|
801 |
}
|
|
|
802 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
803 |
return intval(array_pop($resultat[0]));
|
|
|
804 |
}
|
|
|
805 |
|
|
|
806 |
/**
|
|
|
807 |
* Nombre total d'images Pictoflora ayant au moins un mot-clé
|
|
|
808 |
*/
|
|
|
809 |
private function getNbImagesAyantTag($mpm=false) {
|
|
|
810 |
$requete = "SELECT COUNT(DISTINCT ce_image) AS nb_total FROM del_image_tag";
|
|
|
811 |
if ($this->annee != null) {
|
|
|
812 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
813 |
}
|
|
|
814 |
if ($mpm) {
|
|
|
815 |
$requete = $this->encapsulerMPM($requete);
|
|
|
816 |
}
|
|
|
817 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
818 |
return intval(array_pop($resultat[0]));
|
|
|
819 |
}
|
|
|
820 |
|
|
|
821 |
/**
|
|
|
822 |
* Nombre total d'images Pictoflora ayant au moins un vote
|
|
|
823 |
*/
|
|
|
824 |
private function getNbImagesAyantVote($mpm=false) {
|
|
|
825 |
$requete = "SELECT COUNT(DISTINCT ce_image) AS nb_total FROM del_image_vote";
|
|
|
826 |
if ($this->annee != null) {
|
|
|
827 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
828 |
}
|
|
|
829 |
if ($mpm) {
|
|
|
830 |
$requete = $this->encapsulerMPM($requete);
|
|
|
831 |
}
|
|
|
832 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
833 |
return intval(array_pop($resultat[0]));
|
|
|
834 |
}
|
|
|
835 |
|
|
|
836 |
/**
|
|
|
837 |
* Nombre total d'images Pictoflora de l'année ayant au moins un mot-clé
|
|
|
838 |
*/
|
|
|
839 |
private function getNbImagesAnneeAyantTag($mpm=false) {
|
|
|
840 |
if ($this->annee == null) {
|
|
|
841 |
return null;
|
|
|
842 |
}
|
|
|
843 |
$requete = "SELECT COUNT(DISTINCT ce_image) AS nb_total FROM del_image_tag WHERE YEAR(date) = " . $this->annee
|
|
|
844 |
. " AND ce_image IN (SELECT id_image FROM del_image WHERE year(date_transmission) = " . $this->annee . ")";
|
|
|
845 |
if ($mpm) {
|
|
|
846 |
$requete = $this->encapsulerMPM($requete);
|
|
|
847 |
}
|
|
|
848 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
849 |
return intval(array_pop($resultat[0]));
|
|
|
850 |
}
|
|
|
851 |
|
|
|
852 |
/**
|
|
|
853 |
* Nombre total d'images Pictoflora de l'année ayant au moins un vote
|
|
|
854 |
*/
|
|
|
855 |
private function getNbImagesAnneeAyantVote($mpm=false) {
|
|
|
856 |
if ($this->annee == null) {
|
|
|
857 |
return null;
|
|
|
858 |
}
|
|
|
859 |
$requete = "SELECT COUNT(DISTINCT ce_image) AS nb_total FROM del_image_vote WHERE YEAR(date) = " . $this->annee
|
|
|
860 |
. " AND ce_image IN (SELECT id_image FROM del_image WHERE year(date_transmission) = " . $this->annee . ")";
|
|
|
861 |
if ($mpm) {
|
|
|
862 |
$requete = $this->encapsulerMPM($requete);
|
|
|
863 |
}
|
|
|
864 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
865 |
return intval(array_pop($resultat[0]));
|
|
|
866 |
}
|
|
|
867 |
|
|
|
868 |
/**
|
|
|
869 |
* Statistiques sur les votes et mots-clés (tags) de Pictoflora
|
|
|
870 |
* "MPM" = moyenne par mois
|
|
|
871 |
* - Nombre total de votes
|
|
|
872 |
* - Nombre total de mots clés
|
|
|
873 |
* - Nombre d'images ayant le mot-clé "defiPhoto"
|
|
|
874 |
*/
|
|
|
875 |
private function getTagsVotes() {
|
2011 |
mathias |
876 |
return array(
|
2017 |
mathias |
877 |
'nbTagsTotal' => $this->getNbTagsTotal(),
|
|
|
878 |
'nbTagsTotalMPM' => $this->getNbTagsTotal(true),
|
|
|
879 |
'nbVotesTotal' => $this->getNbVotesTotal(),
|
|
|
880 |
'nbVotesTotalMPM' => $this->getNbVotesTotal(true),
|
|
|
881 |
// devra être paramétré par une liste de mots-clés
|
|
|
882 |
//'nbImagesTagDP' => $this->getNbImagesTagDP(),
|
|
|
883 |
//'nbImagesTagDPMPM' => $this->getNbImagesTagDP(true)
|
2011 |
mathias |
884 |
);
|
|
|
885 |
}
|
|
|
886 |
|
|
|
887 |
/**
|
2017 |
mathias |
888 |
* Nombre total de mots clés Pictoflora
|
2011 |
mathias |
889 |
*/
|
2017 |
mathias |
890 |
private function getNbTagsTotal($mpm=false) {
|
|
|
891 |
$requete = "SELECT COUNT(*) AS nb_total FROM del_image_tag";
|
|
|
892 |
if ($this->annee != null) {
|
|
|
893 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
894 |
}
|
|
|
895 |
if ($mpm) {
|
|
|
896 |
$requete = $this->encapsulerMPM($requete);
|
|
|
897 |
}
|
|
|
898 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
899 |
return intval(array_pop($resultat[0]));
|
|
|
900 |
}
|
|
|
901 |
|
|
|
902 |
/**
|
|
|
903 |
* Nombre total de votes Pictoflora
|
|
|
904 |
*/
|
|
|
905 |
private function getNbVotesTotal($mpm=false) {
|
|
|
906 |
$requete = "SELECT COUNT(*) AS nb_total FROM del_image_vote";
|
|
|
907 |
if ($this->annee != null) {
|
|
|
908 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
909 |
}
|
|
|
910 |
if ($mpm) {
|
|
|
911 |
$requete = $this->encapsulerMPM($requete);
|
|
|
912 |
}
|
|
|
913 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
914 |
return intval(array_pop($resultat[0]));
|
|
|
915 |
}
|
|
|
916 |
|
|
|
917 |
/**
|
|
|
918 |
* Statistiques sur les utilisateurs de Pictoflora
|
|
|
919 |
* "MPM" = Moyenne par mois
|
|
|
920 |
* "AF" = Ayant fait
|
|
|
921 |
* - Nombre d'utilisateurs ayant ajouté un mot-clé
|
|
|
922 |
* - Nombre d'utilisateurs ayant voté
|
|
|
923 |
* - Nombre d'utilisateurs ayant fait une action
|
|
|
924 |
*/
|
2011 |
mathias |
925 |
private function getUtilisateursPf() {
|
|
|
926 |
return array(
|
2017 |
mathias |
927 |
'nbUtilisateursAFTag' => $this->getNbUtilisateursPfAFTag(),
|
|
|
928 |
'nbUtilisateursAFTagMPM' => $this->getNbUtilisateursPfAFTag(true),
|
|
|
929 |
'nbUtilisateursAFVote' => $this->getNbUtilisateursPfAFVote(),
|
|
|
930 |
'nbUtilisateursAFVoteMPM' => $this->getNbUtilisateursPfAFVote(true),
|
|
|
931 |
'nbUtilisateursAFAction' => $this->getNbUtilisateursPfAFAction(),
|
|
|
932 |
'nbUtilisateursAFActionMPM' => $this->getNbUtilisateursPfAFActionMPM()
|
2011 |
mathias |
933 |
);
|
|
|
934 |
}
|
|
|
935 |
|
|
|
936 |
/**
|
2017 |
mathias |
937 |
* Nombre d'utilisateurs ayant ajouté un mot-clé
|
2011 |
mathias |
938 |
*/
|
2017 |
mathias |
939 |
private function getNbUtilisateursPfAFTag($mpm=false) {
|
|
|
940 |
$requete = "SELECT COUNT(DISTINCT ce_utilisateur) AS nb_total FROM del_image_tag";
|
|
|
941 |
if ($this->annee != null) {
|
|
|
942 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
943 |
}
|
|
|
944 |
if ($mpm) {
|
|
|
945 |
$requete = $this->encapsulerMPM($requete);
|
|
|
946 |
}
|
2011 |
mathias |
947 |
$resultat = $this->bdd->recupererTous($requete);
|
2017 |
mathias |
948 |
return intval(array_pop($resultat[0]));
|
2011 |
mathias |
949 |
}
|
|
|
950 |
|
|
|
951 |
/**
|
2017 |
mathias |
952 |
* Nombre d'utilisateurs ayant fait un vote
|
2011 |
mathias |
953 |
*/
|
2017 |
mathias |
954 |
private function getNbUtilisateursPfAFVote($mpm=false) {
|
|
|
955 |
$requete = "SELECT COUNT(DISTINCT ce_utilisateur) AS nb_total FROM del_image_vote";
|
|
|
956 |
if ($this->annee != null) {
|
|
|
957 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
958 |
}
|
|
|
959 |
if ($mpm) {
|
|
|
960 |
$requete = $this->encapsulerMPM($requete);
|
|
|
961 |
}
|
2011 |
mathias |
962 |
$resultat = $this->bdd->recupererTous($requete);
|
2017 |
mathias |
963 |
return intval(array_pop($resultat[0]));
|
2011 |
mathias |
964 |
}
|
|
|
965 |
|
|
|
966 |
/**
|
2017 |
mathias |
967 |
* Nombre d'utilisateurs ayant fait une action
|
2011 |
mathias |
968 |
*/
|
2017 |
mathias |
969 |
private function getNbUtilisateursPfAFAction() {
|
|
|
970 |
$requete = "SELECT COUNT(*) AS nb_total FROM (SELECT ce_utilisateur FROM del_image_tag";
|
|
|
971 |
if ($this->annee != null) {
|
|
|
972 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
973 |
}
|
|
|
974 |
$requete .= " UNION SELECT ce_utilisateur FROM del_image_vote";
|
|
|
975 |
if ($this->annee != null) {
|
|
|
976 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
977 |
}
|
|
|
978 |
$requete .= ") AS action";
|
2011 |
mathias |
979 |
$resultat = $this->bdd->recupererTous($requete);
|
2017 |
mathias |
980 |
return intval(array_pop($resultat[0]));
|
2011 |
mathias |
981 |
}
|
|
|
982 |
|
|
|
983 |
/**
|
2017 |
mathias |
984 |
* Moyenne par mois du nombre d'utilisateurs ayant fait une action
|
|
|
985 |
* -> n'est pas encapsulable par encapsulerMPM()
|
2011 |
mathias |
986 |
*/
|
2017 |
mathias |
987 |
private function getNbUtilisateursPfAFActionMPM() {
|
|
|
988 |
$requete = "SELECT avg(nb_total) FROM (SELECT COUNT(*) AS nb_total FROM (SELECT * FROM (SELECT ce_utilisateur, date FROM del_image_tag";
|
|
|
989 |
if ($this->annee != null) {
|
|
|
990 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
991 |
}
|
|
|
992 |
$requete .= " UNION SELECT ce_utilisateur, date FROM del_image_vote";
|
|
|
993 |
if ($this->annee != null) {
|
|
|
994 |
$requete .= ' WHERE YEAR(date) = ' . $this->annee;
|
|
|
995 |
}
|
|
|
996 |
$requete .= ") AS action GROUP BY ce_utilisateur) AS utildate GROUP BY CONCAT(year(date),month(date))) as truc";
|
2011 |
mathias |
997 |
$resultat = $this->bdd->recupererTous($requete);
|
2017 |
mathias |
998 |
return intval(array_pop($resultat[0]));
|
2011 |
mathias |
999 |
}
|
|
|
1000 |
|
|
|
1001 |
/**
|
2017 |
mathias |
1002 |
* Liste des mots-clés les plus fréquents
|
2011 |
mathias |
1003 |
*/
|
|
|
1004 |
private function getListeMeilleursTags() {
|
|
|
1005 |
$liste = array();
|
2017 |
mathias |
1006 |
$requete = "SELECT count(*) as occurrences, tag FROM del_image_tag";
|
|
|
1007 |
if ($this->annee != null) {
|
|
|
1008 |
$requete .= " WHERE YEAR(date) = " . $this->annee;
|
|
|
1009 |
}
|
|
|
1010 |
$requete .= " GROUP BY tag ORDER BY occurrences DESC LIMIT 20";
|
2011 |
mathias |
1011 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
1012 |
return array(
|
2017 |
mathias |
1013 |
'liste' => $resultat
|
2011 |
mathias |
1014 |
);
|
|
|
1015 |
}
|
|
|
1016 |
|
|
|
1017 |
/**
|
2018 |
mathias |
1018 |
* Liste des utilisateurs ayant ajouté le plus de mots-clés
|
2011 |
mathias |
1019 |
*/
|
|
|
1020 |
private function getListeMeilleursTagueurs() {
|
2017 |
mathias |
1021 |
$resultat = array();
|
2018 |
mathias |
1022 |
$requete = "SELECT count(*) as nombre, IF (ce_utilisateur REGEXP '^-?[0-9]+$', ce_utilisateur, null) as ce_util FROM del_image_tag";
|
2017 |
mathias |
1023 |
if ($this->annee != null) {
|
2018 |
mathias |
1024 |
$requete .= " WHERE year(date) = " . $this->annee;
|
2017 |
mathias |
1025 |
}
|
2018 |
mathias |
1026 |
$requete .= " GROUP BY ce_util ORDER BY nombre DESC LIMIT 20";
|
2011 |
mathias |
1027 |
$resultat = $this->bdd->recupererTous($requete);
|
|
|
1028 |
|
2018 |
mathias |
1029 |
// Formatage de la liste avec les intitulés des utilisateurs
|
|
|
1030 |
$ids = array_column($resultat, 'ce_util');
|
|
|
1031 |
$ids = array_filter($ids, 'is_numeric'); // on oublie les ids de session et autres facéties
|
|
|
1032 |
$infosUtilisateurs = $this->recupererIntitulesUtilisateursParIds($ids, true);
|
|
|
1033 |
foreach ($resultat as &$util) {
|
|
|
1034 |
$ce = $util['ce_util'];
|
|
|
1035 |
$util['intitule'] = isset($infosUtilisateurs[$ce]['intitule']) ? $infosUtilisateurs[$ce]['intitule'] : null;
|
|
|
1036 |
}
|
|
|
1037 |
|
2011 |
mathias |
1038 |
return array(
|
2017 |
mathias |
1039 |
'liste' => $resultat
|
2011 |
mathias |
1040 |
);
|
|
|
1041 |
}
|
2013 |
mathias |
1042 |
|
|
|
1043 |
/**
|
|
|
1044 |
* Encapsule une reqûete de comptage dans un autre morceau de requête
|
|
|
1045 |
* afin de calculer la moyenne par mois
|
|
|
1046 |
* @param string $requete count() qui doit renvoyer une colonne 'nb_total'
|
|
|
1047 |
*/
|
2016 |
mathias |
1048 |
protected function encapsulerMPM($requete, $colonne="date") {
|
2013 |
mathias |
1049 |
$requeteEncapsulee = "SELECT AVG(nb_total) as moyenne FROM ("
|
|
|
1050 |
. $requete
|
2016 |
mathias |
1051 |
. " GROUP BY CONCAT(year($colonne),month($colonne)) ) AS nombre";
|
2013 |
mathias |
1052 |
return $requeteEncapsulee;
|
|
|
1053 |
}
|
2018 |
mathias |
1054 |
|
|
|
1055 |
/**
|
|
|
1056 |
* Prend en paramêtre un tableau d'identifiants utilisateurs et retourne après avoir interrogé un
|
|
|
1057 |
* webservice de l'annuaire un tableau avec en clé l'id et en valeur l'intitulé
|
|
|
1058 |
* @param array $ids un tableau d'ids
|
|
|
1059 |
*/
|
|
|
1060 |
protected function recupererIntitulesUtilisateursParIds(array $ids) {
|
|
|
1061 |
$service = "utilisateur/infos-par-id/" . implode(',', $ids);
|
|
|
1062 |
$url = $this->conteneur->getParametre('urlServiceBaseAnnuaire') . $service;
|
|
|
1063 |
//echo "URL: $url\n\n";
|
|
|
1064 |
$json = $this->conteneur->getRestClient()->consulter($url);
|
|
|
1065 |
$resultat = json_decode($json, true);
|
|
|
1066 |
return $resultat;
|
|
|
1067 |
}
|
1818 |
jpm |
1068 |
}
|