1565 |
mathias |
1 |
<?php
|
1683 |
jpm |
2 |
// declare(encoding='UTF-8');
|
1565 |
mathias |
3 |
/**
|
1683 |
jpm |
4 |
* Script gérant les statistiques de DEL.
|
|
|
5 |
*
|
1867 |
jpm |
6 |
* @category DEL
|
|
|
7 |
* @package Scripts
|
|
|
8 |
* @subpackage Stats
|
|
|
9 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
|
|
10 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
11 |
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
|
|
|
12 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
|
|
13 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
|
|
14 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
1565 |
mathias |
15 |
*/
|
|
|
16 |
class Stats extends DelScript {
|
|
|
17 |
|
|
|
18 |
public function executer() {
|
1683 |
jpm |
19 |
$this->mettreAJourStats();
|
1565 |
mathias |
20 |
}
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* Met à jour la table des statistiques en la vidant et en recalculant la moyenne pondérée,
|
|
|
24 |
* le nombre de votes et le nombre de points pour chaque image - utilise "commun".
|
|
|
25 |
* Attention, c'est over-pas-optimisé, ça prend du temps !
|
|
|
26 |
*/
|
1683 |
jpm |
27 |
private function mettreAJourStats() {
|
1565 |
mathias |
28 |
$requete = "SELECT id_image FROM del_image ORDER BY id_image ASC";
|
|
|
29 |
$ids = $this->getBdd()->recupererTous($requete);
|
|
|
30 |
|
|
|
31 |
$requete = "SELECT id_protocole FROM del_image_protocole ORDER BY id_protocole ASC";
|
|
|
32 |
$protos = $this->getBdd()->recupererTous($requete);
|
|
|
33 |
|
|
|
34 |
foreach ($ids as $id) {
|
|
|
35 |
echo "ID: " . $id['id_image'] . "\n";
|
|
|
36 |
foreach ($protos as $proto) {
|
|
|
37 |
TelaBotanica\Del\Commun\Stats::updateStats($this->getBdd(), $id['id_image'], $proto['id_protocole']);
|
|
|
38 |
}
|
|
|
39 |
}
|
|
|
40 |
}
|
|
|
41 |
}
|