Skip to content

Commit

Permalink
Only get the last 7 days in the week count calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviocopes committed Oct 6, 2015
1 parent 5f502b4 commit 4f62917
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions classes/popularity.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct()
}

public function trackHit()
{
{
// Don't track bot or crawler requests
if (!self::getGrav()['browser']->isHuman()) {
return;
Expand Down Expand Up @@ -149,9 +149,12 @@ public function getWeeklyTotal()
$this->daily_data = $this->getData($this->daily_file);
}

$day = 0;
$total = 0;
foreach ($this->daily_data as $daily) {
foreach (array_reverse($this->daily_data) as $daily) {
$total += $daily;
$day++;
if ($day == 7) break;
}

return $total;
Expand Down

0 comments on commit 4f62917

Please sign in to comment.