Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
JhumanJ authored and actions-user committed Sep 11, 2021
1 parent 07d8360 commit 5231683
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 6 additions & 2 deletions src/Http/Controllers/StatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ public function widgetData(DataRequest $request)
case 'period_total':
return $modelStats->getPeriodTotal($dateFrom, $dateTo, $request->date_column);
case 'group_by_count':
return $modelStats->getGroupByCount($dateFrom, $dateTo, $request->date_column,
$request->aggregate_column);
return $modelStats->getGroupByCount(
$dateFrom,
$dateTo,
$request->date_column,
$request->aggregate_column
);
default:
throw new \Exception('Wigdet aggregate type not supported.');
}
Expand Down
6 changes: 3 additions & 3 deletions src/Http/Requests/Widgets/DataRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class DataRequest extends FormRequest
'daily_count',
'cumulated_daily_count',
'period_total',
'group_by_count'
'group_by_count',
];

const AGGREGATES_TYPES_WITH_AGGREGATE_COLUMN = [
'group_by_count'
'group_by_count',
];

/**
Expand All @@ -36,7 +36,7 @@ public function rules()
'date_column' => 'required',
'date_from' => 'required|date_format:Y-m-d|before:date_to',
'date_to' => 'required|date_format:Y-m-d|after:date_from',
'aggregate_column' => [Rule::requiredIf( in_array(request()->aggregate_type, self::AGGREGATES_TYPES_WITH_AGGREGATE_COLUMN))],
'aggregate_column' => [Rule::requiredIf(in_array(request()->aggregate_type, self::AGGREGATES_TYPES_WITH_AGGREGATE_COLUMN))],
];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Services/ModelStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ public static function fillMissingDays($data, Carbon $since, Carbon $to, $defaul

foreach (array_reverse(range(0, $daysSince)) as $number) {
$dateKey = $to->copy()->subDays($number)->format('Y-m-d');
if (!isset($data[$dateKey])) {
if (! isset($data[$dateKey])) {
$data[$dateKey] = $defaultValue;
}

if (!is_null($cumulatedSum)) {
if (! is_null($cumulatedSum)) {
$data[$dateKey] += $cumulatedSum;
$cumulatedSum = $data[$dateKey];
}
Expand Down

0 comments on commit 5231683

Please sign in to comment.