Subversion Repositories eFlore/Applications.del

Rev

Rev 1621 | Details | Compare with Previous | Last modification | View Log | RSS feed

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