Skip to content

Added "Today" to dashboard report #33874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/code/Magento/Backend/Model/Dashboard/Chart/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public function getByPeriod(string $period): array

if ($period === Period::PERIOD_24_HOURS) {
$dateEnd->modify('-1 hour');
} elseif ($period === Period::PERIOD_TODAY) {
$dateEnd->modify('now');
} else {
$dateEnd->setTime(23, 59, 59);
$dateStart->setTime(0, 0, 0);
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Backend/Model/Dashboard/Period.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
class Period
{
public const PERIOD_TODAY = 'today';
public const PERIOD_24_HOURS = '24h';
public const PERIOD_7_DAYS = '7d';
public const PERIOD_1_MONTH = '1m';
Expand All @@ -30,6 +31,7 @@ class Period
public function getDatePeriods(): array
{
return [
static::PERIOD_TODAY => __('Today'),
static::PERIOD_24_HOURS => __('Last 24 Hours'),
static::PERIOD_7_DAYS => __('Last 7 Days'),
static::PERIOD_1_MONTH => __('Current Month'),
Expand All @@ -46,6 +48,7 @@ public function getDatePeriods(): array
public function getPeriodChartUnits(): array
{
return [
static::PERIOD_TODAY => self::PERIOD_UNIT_HOUR,
static::PERIOD_24_HOURS => self::PERIOD_UNIT_HOUR,
static::PERIOD_7_DAYS => self::PERIOD_UNIT_DAY,
static::PERIOD_1_MONTH => self::PERIOD_UNIT_DAY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function testGetDatePeriods()
{
$this->assertEquals(
[
Period::PERIOD_TODAY => (string)__('Today'),
Period::PERIOD_24_HOURS => (string)__('Last 24 Hours'),
Period::PERIOD_7_DAYS => (string)__('Last 7 Days'),
Period::PERIOD_1_MONTH => (string)__('Current Month'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ protected function _prepareSummaryAggregated($range, $customStart, $customEnd)
protected function _getRangeExpression($range)
{
switch ($range) {
case 'today':
case '24h':
$expression = $this->getConnection()->getConcatSql(
[
Expand Down Expand Up @@ -420,6 +421,9 @@ public function getDateRange($range, $customStart, $customEnd, $returnObjects =
$dateStart->setTime(0, 0, 0);

switch ($range) {
case 'today':
$dateEnd->modify('now');
break;
case '24h':
$dateEnd = new \DateTime();
$dateEnd->modify('+1 hour');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public function testChartPeriodOptions(): void
{
$html = $this->block->toHtml();
$dropDownList = [
__('Today'),
__('Last 24 Hours'),
__('Last 7 Days'),
__('Current Month'),
Expand Down