diff options
| author | 2014-01-26 06:49:35 -0800 | |
|---|---|---|
| committer | 2014-01-26 06:49:35 -0800 | |
| commit | 220c314eedb560f2e269f0da84869e643d40f737 (patch) | |
| tree | 11f626c93e1efc6669caf15024d79fa71624ea32 /app/Models/StatsDAO.php | |
| parent | c2998ffc97fbb8e45e6179f5d9c59c1b940d5782 (diff) | |
| parent | 964128bd5fba878f97da04d6828692d123e2ffd4 (diff) | |
Merge pull request #394 from aledeg/statistics
Modification des statistiques.
Diffstat (limited to 'app/Models/StatsDAO.php')
| -rw-r--r-- | app/Models/StatsDAO.php | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/app/Models/StatsDAO.php b/app/Models/StatsDAO.php index a317c8f27..60cec7847 100644 --- a/app/Models/StatsDAO.php +++ b/app/Models/StatsDAO.php @@ -122,6 +122,7 @@ FROM {$this->prefix}category AS c, {$this->prefix}feed AS f WHERE c.id = f.category GROUP BY label +ORDER BY data DESC SQL; $stm = $this->bd->prepare($sql); $stm->execute(); @@ -146,6 +147,7 @@ FROM {$this->prefix}category AS c, WHERE c.id = f.category AND f.id = e.id_feed GROUP BY label +ORDER BY data DESC SQL; $stm = $this->bd->prepare($sql); $stm->execute(); @@ -154,6 +156,31 @@ SQL; return $this->convertToPieSerie($res); } + /** + * Calculates the 10 top feeds based on their number of entries + * + * @return array + */ + public function calculateTopFeed() { + $sql = <<<SQL +SELECT f.id AS id +, MAX(f.name) AS name +, MAX(c.name) AS category +, COUNT(e.id) AS count +FROM {$this->prefix}category AS c, +{$this->prefix}feed AS f, +{$this->prefix}entry AS e +WHERE c.id = f.category +AND f.id = e.id_feed +GROUP BY id +ORDER BY count DESC +LIMIT 10 +SQL; + $stm = $this->bd->prepare($sql); + $stm->execute(); + return $stm->fetchAll(PDO::FETCH_ASSOC); + } + private function convertToSerie($data) { $serie = array(); @@ -168,7 +195,7 @@ SQL; $serie = array(); foreach ($data as $value) { - $value['data'] = array(array(0, (int)$value['data'])); + $value['data'] = array(array(0, (int) $value['data'])); $serie[] = $value; } |
