From 35f633b4c71c087d1ddc9bba9e9bbe18de09204f Mon Sep 17 00:00:00 2001
From: Benjamin Bellamy <ben@podlibre.org>
Date: Thu, 8 Oct 2020 18:42:00 +0200
Subject: [PATCH] fix: re-order graph values

---
 app/Models/AnalyticsPodcastByCountryModel.php   | 2 +-
 app/Models/AnalyticsPodcastByRegionModel.php    | 2 +-
 app/Models/AnalyticsWebsiteByBrowserModel.php   | 2 +-
 app/Models/AnalyticsWebsiteByEntryPageModel.php | 3 ++-
 app/Models/AnalyticsWebsiteByRefererModel.php   | 6 ++++--
 5 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/app/Models/AnalyticsPodcastByCountryModel.php b/app/Models/AnalyticsPodcastByCountryModel.php
index d26b586845..d8e8c9b550 100644
--- a/app/Models/AnalyticsPodcastByCountryModel.php
+++ b/app/Models/AnalyticsPodcastByCountryModel.php
@@ -40,7 +40,7 @@ class AnalyticsPodcastByCountryModel extends Model
                     '`podcast_id`' => $podcastId,
                     '`date` >' => date('Y-m-d', strtotime('-1 week')),
                 ])
-                ->orderBy('`labels`', 'ASC')
+                ->orderBy('`values`', 'DESC')
                 ->findAll();
 
             cache()->save(
diff --git a/app/Models/AnalyticsPodcastByRegionModel.php b/app/Models/AnalyticsPodcastByRegionModel.php
index 9953fbe2e0..d384011640 100644
--- a/app/Models/AnalyticsPodcastByRegionModel.php
+++ b/app/Models/AnalyticsPodcastByRegionModel.php
@@ -44,7 +44,7 @@ class AnalyticsPodcastByRegionModel extends Model
                     '`podcast_id`' => $podcastId,
                     '`date` >' => date('Y-m-d', strtotime('-1 week')),
                 ])
-                ->orderBy('`country_code`, `region_code`', 'ASC')
+                ->orderBy('`values`', 'DESC')
                 ->findAll();
 
             cache()->save(
diff --git a/app/Models/AnalyticsWebsiteByBrowserModel.php b/app/Models/AnalyticsWebsiteByBrowserModel.php
index 4d5c0e2801..3e3fdce579 100644
--- a/app/Models/AnalyticsWebsiteByBrowserModel.php
+++ b/app/Models/AnalyticsWebsiteByBrowserModel.php
@@ -40,7 +40,7 @@ class AnalyticsWebsiteByBrowserModel extends Model
                     '`podcast_id`' => $podcastId,
                     '`date` >' => date('Y-m-d', strtotime('-1 week')),
                 ])
-                ->orderBy('`browser`', 'ASC')
+                ->orderBy('`values`', 'DESC')
                 ->findAll();
 
             cache()->save(
diff --git a/app/Models/AnalyticsWebsiteByEntryPageModel.php b/app/Models/AnalyticsWebsiteByEntryPageModel.php
index 91c4053a1f..352017f2b0 100644
--- a/app/Models/AnalyticsWebsiteByEntryPageModel.php
+++ b/app/Models/AnalyticsWebsiteByEntryPageModel.php
@@ -40,7 +40,8 @@ class AnalyticsWebsiteByEntryPageModel extends Model
                     '`podcast_id`' => $podcastId,
                     '`date` >' => date('Y-m-d', strtotime('-1 week')),
                 ])
-                ->orderBy('`entry_page`', 'ASC')
+                ->orderBy('`values`', 'DESC')
+                ->limit(10)
                 ->findAll();
 
             cache()->save(
diff --git a/app/Models/AnalyticsWebsiteByRefererModel.php b/app/Models/AnalyticsWebsiteByRefererModel.php
index e45ea20ba2..9f414bcf40 100644
--- a/app/Models/AnalyticsWebsiteByRefererModel.php
+++ b/app/Models/AnalyticsWebsiteByRefererModel.php
@@ -40,7 +40,8 @@ class AnalyticsWebsiteByRefererModel extends Model
                     '`podcast_id`' => $podcastId,
                     '`date` >' => date('Y-m-d', strtotime('-1 week')),
                 ])
-                ->orderBy('`referer`', 'ASC')
+                ->orderBy('`values`', 'DESC')
+                ->limit(10)
                 ->findAll();
 
             cache()->save(
@@ -69,7 +70,8 @@ class AnalyticsWebsiteByRefererModel extends Model
                     '`podcast_id`' => $podcastId,
                     '`date` >' => date('Y-m-d', strtotime('-1 week')),
                 ])
-                ->orderBy('`domain`', 'ASC')
+                ->orderBy('`values`', 'DESC')
+                ->limit(10)
                 ->findAll();
 
             cache()->save(
-- 
GitLab