From 518868d7e31f90107a3e094f7c97a08b980cc136 Mon Sep 17 00:00:00 2001 From: Nick Muerdter <12112+GUI@users.noreply.github.com> Date: Wed, 14 Feb 2024 08:04:32 -0700 Subject: [PATCH] Change default analytics viewing to last 14 days. --- .../admin-ui/app/components/stats/query-form.js | 2 +- .../admin-ui/app/controllers/stats/base.js | 2 +- src/api-umbrella/admin-ui/app/routes/stats/base.js | 9 +++++++-- .../api_umbrella_test_helpers/date_range_picker.rb | 12 +++++++++--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/api-umbrella/admin-ui/app/components/stats/query-form.js b/src/api-umbrella/admin-ui/app/components/stats/query-form.js index 347e12265..d1b151e6c 100644 --- a/src/api-umbrella/admin-ui/app/components/stats/query-form.js +++ b/src/api-umbrella/admin-ui/app/components/stats/query-form.js @@ -544,7 +544,7 @@ export default class QueryForm extends Component { // "end_at" take precedence), so reset it back to the default value // (defined in app/controllers/stats/base.js), so it's hidden from the // URL. - date_range: '30d', + date_range: '14d', }); } } diff --git a/src/api-umbrella/admin-ui/app/controllers/stats/base.js b/src/api-umbrella/admin-ui/app/controllers/stats/base.js index 25bec7708..dc063da19 100644 --- a/src/api-umbrella/admin-ui/app/controllers/stats/base.js +++ b/src/api-umbrella/admin-ui/app/controllers/stats/base.js @@ -5,7 +5,7 @@ export default class BaseController extends Controller { interval = 'day'; prefix = '0/'; region = 'world'; - date_range = '30d'; + date_range = '14d'; start_at = ''; end_at = ''; query = JSON.stringify({ diff --git a/src/api-umbrella/admin-ui/app/routes/stats/base.js b/src/api-umbrella/admin-ui/app/routes/stats/base.js index fb9e35d2c..ca473a96d 100644 --- a/src/api-umbrella/admin-ui/app/routes/stats/base.js +++ b/src/api-umbrella/admin-ui/app/routes/stats/base.js @@ -32,12 +32,17 @@ export default class BaseRoute extends AuthenticatedRoute { }, 'yesterday': { label: 'Yesterday', - start_at: moment().tz(timezone).subtract(1, 'days'), + start_at: moment().tz(timezone).subtract(1, 'days').startOf('day'), end_at: moment().tz(timezone).subtract(1, 'days').endOf('day'), }, '7d': { label: 'Last 7 Days', - start_at: moment().tz(timezone).subtract(6, 'days'), + start_at: moment().tz(timezone).subtract(6, 'days').startOf('day'), + end_at: moment().tz(timezone).endOf('day'), + }, + '14d': { + label: 'Last 14 Days', + start_at: moment().tz(timezone).subtract(13, 'days').startOf('day'), end_at: moment().tz(timezone).endOf('day'), }, '30d': { diff --git a/test/support/api_umbrella_test_helpers/date_range_picker.rb b/test/support/api_umbrella_test_helpers/date_range_picker.rb index cfffd9f0f..5ffaadd7c 100644 --- a/test/support/api_umbrella_test_helpers/date_range_picker.rb +++ b/test/support/api_umbrella_test_helpers/date_range_picker.rb @@ -19,10 +19,10 @@ def assert_date_range_picker(fragment_path) # local time. page.execute_script("timekeeper.travel(Date.UTC(2015, 0, 24, 3, 0))") - # Defaults to last 30 days. + # Defaults to last 14 days. visit "/admin/##{fragment_path}" - assert_download_csv_link_date_range("2014-12-25", "2015-01-23") - assert_date_range_picker_date_range("Last 30 Days", "2014-12-25", "2015-01-23") + assert_download_csv_link_date_range("2015-01-10", "2015-01-23") + assert_date_range_picker_date_range("Last 14 Days", "2015-01-10", "2015-01-23") assert_current_admin_url(fragment_path, nil) # Direct link to last 7 days. @@ -60,6 +60,12 @@ def assert_date_range_picker(fragment_path) change_date_picker("Last 30 Days") assert_download_csv_link_date_range("2014-12-25", "2015-01-23") assert_date_range_picker_date_range("Last 30 Days", "2014-12-25", "2015-01-23") + assert_current_admin_url(fragment_path, { "date_range" => "30d" }) + + # Change to last 14 days in UI. + change_date_picker("Last 14 Days") + assert_download_csv_link_date_range("2015-01-10", "2015-01-23") + assert_date_range_picker_date_range("Last 14 Days", "2015-01-10", "2015-01-23") assert_current_admin_url(fragment_path, nil) # Change to a custom range in UI.