Subversion Repositories eFlore/Applications.del

Rev

Rev 1565 | Rev 1867 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?php
// declare(encoding='UTF-8');
/**
 * Script gérant les statistiques de DEL.
 *
 * @category    php 5.4
 * @package             DEL
 * @subpackage  Scripts
 * @author              Mathias CHOUET <mathias@tela-botanica.org>
 * @copyright   Copyright (c) 2014, Tela Botanica (accueil@tela-botanica.org)
 * @license             CeCILL v2 http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt
 * @license             GNU-GPL http://www.gnu.org/licenses/gpl.html
 */
class Stats extends DelScript {

        public function executer() {
                $this->mettreAJourStats();
        }

        /**
         * Met à jour la table des statistiques en la vidant et en recalculant la moyenne pondérée,
         * le nombre de votes et le nombre de points pour chaque image - utilise "commun".
         * Attention, c'est over-pas-optimisé, ça prend du temps !
         */
        private function mettreAJourStats() {
                $requete = "SELECT id_image FROM del_image ORDER BY id_image ASC";
                $ids = $this->getBdd()->recupererTous($requete);

                $requete = "SELECT id_protocole FROM del_image_protocole ORDER BY id_protocole ASC";
                $protos = $this->getBdd()->recupererTous($requete);

                foreach ($ids as $id) {
                        echo "ID: " . $id['id_image'] . "\n";
                        foreach ($protos as $proto) {
                                TelaBotanica\Del\Commun\Stats::updateStats($this->getBdd(), $id['id_image'], $proto['id_protocole']);
                        }
                }
        }
}