Skip to content

Commit

Permalink
Change default analytics viewing to last 14 days.
Browse files Browse the repository at this point in the history
  • Loading branch information
GUI committed Feb 14, 2024
1 parent 980f5da commit 518868d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/api-umbrella/admin-ui/app/controllers/stats/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
9 changes: 7 additions & 2 deletions src/api-umbrella/admin-ui/app/routes/stats/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down
12 changes: 9 additions & 3 deletions test/support/api_umbrella_test_helpers/date_range_picker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 518868d

Please sign in to comment.