index.phtml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. declare(strict_types=1);
  3. /** @var FreshRSS_ViewStats $this */
  4. $this->partial('aside_subscription');
  5. ?>
  6. <main class="post">
  7. <div class="link-back-wrapper">
  8. <a class="link-back" href="<?= _url('index', 'index') ?>"><?= _t('gen.action.back_to_rss_feeds') ?></a>
  9. </div>
  10. <h1><?= _t('admin.stats.main') ?></h1>
  11. <div class="stat-grid">
  12. <div class="stat half">
  13. <h2><?= _t('admin.stats.entry_repartition') ?></h2>
  14. <div class="table-wrapper scrollbar-thin">
  15. <table>
  16. <thead>
  17. <tr>
  18. <th> </th>
  19. <th><?= _t('admin.stats.main_stream') ?></th>
  20. <th><?= _t('admin.stats.all_feeds') ?></th>
  21. </tr>
  22. </thead>
  23. <tbody>
  24. <tr>
  25. <th><?= _t('admin.stats.status_total') ?></th>
  26. <td class="numeric"><?= format_number($this->repartitions['main_stream']['total'] ?? -1) ?></td>
  27. <td class="numeric"><?= format_number($this->repartitions['all_feeds']['total'] ?? -1) ?></td>
  28. </tr>
  29. <tr>
  30. <th><?= _t('admin.stats.status_read') ?></th>
  31. <td class="numeric"><?= format_number($this->repartitions['main_stream']['count_reads'] ?? -1) ?></td>
  32. <td class="numeric"><?= format_number($this->repartitions['all_feeds']['count_reads'] ?? -1) ?></td>
  33. </tr>
  34. <tr>
  35. <th><?= _t('admin.stats.status_unread') ?></th>
  36. <td class="numeric"><?= format_number($this->repartitions['main_stream']['count_unreads'] ?? -1) ?></td>
  37. <td class="numeric"><?= format_number($this->repartitions['all_feeds']['count_unreads'] ?? -1) ?></td>
  38. </tr>
  39. <tr>
  40. <th><?= _t('admin.stats.status_favorites') ?></th>
  41. <td class="numeric"><?= format_number($this->repartitions['main_stream']['count_favorites'] ?? -1) ?></td>
  42. <td class="numeric"><?= format_number($this->repartitions['all_feeds']['count_favorites'] ?? -1) ?></td>
  43. </tr>
  44. </tbody>
  45. </table>
  46. </div>
  47. </div>
  48. <div class="stat half">
  49. <h2><?= _t('admin.stats.top_feed') ?></h2>
  50. <div class="table-wrapper scrollbar-thin">
  51. <table>
  52. <thead>
  53. <tr>
  54. <th><?= _t('admin.stats.feed') ?></th>
  55. <th><?= _t('admin.stats.category') ?></th>
  56. <th><?= _t('admin.stats.entry_count') ?></th>
  57. <th><?= _t('admin.stats.percent_of_total') ?></th>
  58. </tr>
  59. </thead>
  60. <tbody>
  61. <?php foreach ($this->topFeed as $feed): ?>
  62. <tr>
  63. <td><a href="<?= _url('stats', 'repartition', 'id', $feed['id']) ?>"><?= $feed['name'] ?></a></td>
  64. <td><?= $feed['category'] ?></td>
  65. <td class="numeric"><?= format_number($feed['count']) ?></td>
  66. <td class="numeric"><?php
  67. if (!empty($this->repartitions['all_feeds']['total'])) {
  68. echo format_number($feed['count'] / $this->repartitions['all_feeds']['total'] * 100, 1);
  69. }
  70. ?></td>
  71. </tr>
  72. <?php endforeach; ?>
  73. </tbody>
  74. </table>
  75. </div>
  76. </div>
  77. <div class="stat">
  78. <h2><?= _t('admin.stats.entry_per_day') ?></h2>
  79. <div>
  80. <canvas id="statsEntriesPerDay"></canvas>
  81. <script class="jsonData-stats" type="application/json">
  82. <?= json_encode([
  83. 'canvasID' => 'statsEntriesPerDay',
  84. 'charttype' => 'barWithAverage',
  85. 'labelBarChart' => _t('admin.stats.entry_count'),
  86. 'dataBarChart' => $this->entryCount,
  87. 'labelAverage' => 'Average (' . $this->average . ')',
  88. 'dataAverage' => $this->average,
  89. 'xAxisLabels' => $this->last30DaysLabels,
  90. ], JSON_UNESCAPED_UNICODE)
  91. ?></script>
  92. </div>
  93. </div>
  94. <div class="stat half">
  95. <h2><?= _t('admin.stats.feed_per_category') ?></h2>
  96. <div>
  97. <canvas id="statsFeedsPerCategory"></canvas>
  98. <script class="jsonData-stats" type="application/json">
  99. <?php
  100. echo json_encode(array(
  101. 'canvasID' => 'statsFeedsPerCategory',
  102. 'charttype' => 'doughnut',
  103. 'data' => $this->feedByCategory['data'],
  104. 'labels' => $this->feedByCategory['label'],
  105. ), JSON_UNESCAPED_UNICODE);
  106. ?></script>
  107. </div>
  108. </div>
  109. <div class="stat half">
  110. <h2><?= _t('admin.stats.entry_per_category') ?></h2>
  111. <div>
  112. <canvas id="statsEntriesPerCategory"></canvas>
  113. <script class="jsonData-stats" type="application/json">
  114. <?php
  115. echo json_encode(array(
  116. 'canvasID' => 'statsEntriesPerCategory',
  117. 'charttype' => 'doughnut',
  118. 'data' => $this->entryByCategory['data'],
  119. 'labels' => $this->entryByCategory['label'],
  120. ), JSON_UNESCAPED_UNICODE);
  121. ?></script>
  122. </div>
  123. </div>
  124. </div>
  125. </main>
  126. <script src="../scripts/statsWithChartjs.js?<?= @filemtime(PUBLIC_PATH . '/scripts/statsWithChartjs.js') ?>"></script>