feat(analytics): add 'other' group to pie charts in order to display more accurate data

This commit is contained in:
Benjamin Bellamy 2020-11-03 14:14:30 +00:00
commit 73acef933f
7 changed files with 44 additions and 75 deletions

View file

@ -33,16 +33,16 @@ class AnalyticsWebsiteByBrowserModel extends Model
public function getData(int $podcastId): array
{
if (!($found = cache("{$podcastId}_analytics_website_by_browser"))) {
$oneWeekAgo = date('Y-m-d', strtotime('-1 week'));
$found = $this->select('`browser` as `labels`')
->selectSum('`hits`', '`values`')
->where([
'`podcast_id`' => $podcastId,
'`date` >' => date('Y-m-d', strtotime('-1 week')),
'`date` >' => $oneWeekAgo,
])
->groupBy('`labels`')
->orderBy('`values`', 'DESC')
->findAll(10);
->findAll();
cache()->save(
"{$podcastId}_analytics_website_by_browser",
$found,