Merge pull request #394 from aledeg/statistics

Modification des statistiques.
pull/398/head
Alexandre Alapetite 11 years ago
commit 220c314eed
  1. 1
      app/Controllers/indexController.php
  2. 29
      app/Models/StatsDAO.php
  3. 4
      app/i18n/en.php
  4. 4
      app/i18n/fr.php
  5. 37
      app/views/index/stats.phtml
  6. 17
      p/themes/Dark/freshrss.css
  7. 6
      p/themes/Flat/freshrss.css
  8. 6
      p/themes/Origine/freshrss.css

@ -200,6 +200,7 @@ class FreshRSS_index_Controller extends Minz_ActionController {
$this->view->count = ($statsDAO->calculateEntryCount());
$this->view->feedByCategory = $statsDAO->calculateFeedByCategory();
$this->view->entryByCategory = $statsDAO->calculateEntryByCategory();
$this->view->topFeed = $statsDAO->calculateTopFeed();
}
public function aboutAction () {

@ -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;
}

@ -11,6 +11,8 @@ return array (
'users' => 'Users',
'categories' => 'Categories',
'category' => 'Category',
'feed' => 'Feed',
'feeds' => 'Feeds',
'shortcuts' => 'Shortcuts',
'about' => 'About',
'stats' => 'Statistics',
@ -309,4 +311,6 @@ return array (
'stats_entry_per_day' => 'Entries per day (last 30 days)',
'stats_feed_per_category' => 'Feeds per category',
'stats_entry_per_category' => 'Entries per category',
'stats_top_feed' => 'Top ten feeds',
'stats_entry_count' => 'Entry count',
);

@ -11,6 +11,8 @@ return array (
'users' => 'Utilisateurs',
'categories' => 'Catégories',
'category' => 'Catégorie',
'feed' => 'Flux',
'feeds' => 'Flux',
'shortcuts' => 'Raccourcis',
'about' => 'À propos',
'stats' => 'Statistiques',
@ -309,4 +311,6 @@ return array (
'stats_entry_per_day' => 'Nombre d’articles par jour (30 derniers jours)',
'stats_feed_per_category' => 'Flux par catégorie',
'stats_entry_per_category' => 'Articles par catégorie',
'stats_top_feed' => 'Les dix plus gros flux',
'stats_entry_count' => 'Nombre d’articles',
);

@ -16,23 +16,23 @@
<tbody>
<tr>
<th><?php echo Minz_Translate::t ('status_total')?></th>
<td><?php echo $this->repartition['main_stream']['total']?></td>
<td><?php echo $this->repartition['all_feeds']['total']?></td>
<td class="numeric"><?php echo $this->repartition['main_stream']['total']?></td>
<td class="numeric"><?php echo $this->repartition['all_feeds']['total']?></td>
</tr>
<tr>
<th><?php echo Minz_Translate::t ('status_read')?></th>
<td><?php echo $this->repartition['main_stream']['read']?></td>
<td><?php echo $this->repartition['all_feeds']['read']?></td>
<td class="numeric"><?php echo $this->repartition['main_stream']['read']?></td>
<td class="numeric"><?php echo $this->repartition['all_feeds']['read']?></td>
</tr>
<tr>
<th><?php echo Minz_Translate::t ('status_unread')?></th>
<td><?php echo $this->repartition['main_stream']['unread']?></td>
<td><?php echo $this->repartition['all_feeds']['unread']?></td>
<td class="numeric"><?php echo $this->repartition['main_stream']['unread']?></td>
<td class="numeric"><?php echo $this->repartition['all_feeds']['unread']?></td>
</tr>
<tr>
<th><?php echo Minz_Translate::t ('status_favorites')?></th>
<td><?php echo $this->repartition['main_stream']['favorite']?></td>
<td><?php echo $this->repartition['all_feeds']['favorite']?></td>
<td class="numeric"><?php echo $this->repartition['main_stream']['favorite']?></td>
<td class="numeric"><?php echo $this->repartition['all_feeds']['favorite']?></td>
</tr>
</tbody>
</table>
@ -55,6 +55,27 @@
<div id="statsEntryPerCategoryLegend"></div>
</div>
<div class="stat">
<h2><?php echo Minz_Translate::t ('stats_top_feed')?></h2>
<table>
<thead>
<tr>
<th><?php echo Minz_Translate::t ('feed')?></th>
<th><?php echo Minz_Translate::t ('category')?></th>
<th><?php echo Minz_Translate::t ('stats_entry_count')?></th>
</tr>
</thead>
<tbody>
<?php foreach ($this->topFeed as $feed):?>
<tr>
<td><?php echo $feed['name']?></td>
<td><?php echo $feed['category']?></td>
<td class="numeric"><?php echo $feed['count']?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
</div>
<script>

@ -877,14 +877,13 @@ input.extend {
}
.stat {
border:1px solid #aaa;
border:1px solid #2f2f2f;
border-radius:10px;
box-shadow:2px 2px 5px #aaa;
margin:10px 0;
padding:0 5px;
}
.stat > h2 {
border-bottom:1px solid #aaa;
border-bottom:1px solid #2f2f2f;
margin:0 -5px;
padding-left:5px;
}
@ -894,21 +893,25 @@ input.extend {
.stat > table {
border-collapse:collapse;
margin:5px 0;
text-align:center;
width:100%;
}
.stat > table > thead > tr {
border-bottom:2px solid #aaa;
border-bottom:2px solid #2f2f2f;
}
.stat > table > tbody > tr {
border-bottom:1px solid #aaa;
border-bottom:1px solid #2f2f2f;
}
.stat > table > tbody > tr:last-child {
border-bottom:0;
}
.stat > table th, .stat > table td {
border-left:2px solid #aaa;
border-left:2px solid #2f2f2f;
padding:5px;
}
.stat > table th:first-child, .stat > table td:first-child {
border-left:0;
}
.stat > table td.numeric{
margin:5px 0;
text-align:center;
}

@ -861,7 +861,6 @@ input.extend {
.stat > table {
border-collapse:collapse;
margin:5px 0;
text-align:center;
width:100%;
}
.stat > table > thead > tr {
@ -875,7 +874,12 @@ input.extend {
}
.stat > table th, .stat > table td {
border-left:2px solid #aaa;
padding:5px;
}
.stat > table th:first-child, .stat > table td:first-child {
border-left:0;
}
.stat > table td.numeric{
margin:5px 0;
text-align:center;
}

@ -917,7 +917,6 @@ input.extend {
.stat > table {
border-collapse:collapse;
margin:5px 0;
text-align:center;
width:100%;
}
.stat > table > thead > tr {
@ -931,7 +930,12 @@ input.extend {
}
.stat > table th, .stat > table td {
border-left:2px solid #aaa;
padding:5px;
}
.stat > table th:first-child, .stat > table td:first-child {
border-left:0;
}
.stat > table td.numeric{
margin:5px 0;
text-align:center;
}
Loading…
Cancel
Save