Skip to content

Commit

Permalink
Remove redundant date range options and add a 90-day range option.
Browse files Browse the repository at this point in the history
  • Loading branch information
murdercode committed Mar 7, 2024
1 parent e4e1578 commit 2e52c95
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/Abstract/GoogleAnalyticsCounter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ public function __construct(string $name = null)
$this->name = $name ?? __($this->title);
}

/**
* Return data from Google Analytics API
*/
public function getData(NovaRequest $request, string $metrics): mixed
{
$analyticsData = Analytics::get(Period::days($request->range), [$metrics]);
$results = $analyticsData[0][$metrics];

return $results;
}

/**
* Get the ranges available for the metric.
*
Expand All @@ -40,10 +29,8 @@ public function ranges()
7 => Nova::__('7 Days'),
30 => Nova::__('30 Days'),
60 => Nova::__('60 Days'),
365 => Nova::__('365 Days'),
'MTD' => Nova::__('Month To Date'),
'QTD' => Nova::__('Quarter To Date'),
'YTD' => Nova::__('Year To Date'),
90 => Nova::__('90 Days'),
365 => Nova::__('365 Days')
];
}

Expand Down Expand Up @@ -74,4 +61,15 @@ public function calculate(NovaRequest $request)

return $this->result($results)->format($format);
}

/**
* Return data from Google Analytics API
*/
public function getData(NovaRequest $request, string $metrics): mixed
{
$analyticsData = Analytics::get(Period::days($request->range), [$metrics]);
$results = $analyticsData[0][$metrics];

return $results;
}
}

0 comments on commit 2e52c95

Please sign in to comment.