Subversion Repositories eFlore/Applications.del

Rev

Rev 1683 | 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   DEL
 * @package    Scripts
 * @subpackage Stats
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
 */
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']);
                        }
                }
        }
}