Fixed validations and response naming in aggregate time entries endpoint

This commit is contained in:
Constantin Graf
2024-05-19 12:06:20 +02:00
parent 2e0db46fff
commit 68ecc1227d
3 changed files with 16 additions and 16 deletions

View File

@@ -128,17 +128,17 @@ class TimeEntryController extends Controller
* data: array{ * data: array{
* grouped_data: null|array<array{ * grouped_data: null|array<array{
* type: string, * type: string,
* value: string|null, * key: string|null,
* aggregate: int, * seconds: int,
* cost: int, * cost: int,
* grouped_data: null|array<array{ * grouped_data: null|array<array{
* type: string, * type: string,
* value: string|null, * key: string|null,
* aggregate: int, * seconds: int,
* cost: int * cost: int
* }> * }>
* }>, * }>,
* aggregate: int, * seconds: int,
* cost: int * cost: int
* } * }
* } * }
@@ -224,8 +224,8 @@ class TimeEntryController extends Controller
/** @var string $group2Type */ /** @var string $group2Type */
$group2Response[] = [ $group2Response[] = [
'type' => $group2Type, 'type' => $group2Type,
'value' => $group2 === '' ? null : $group2, 'key' => $group2 === '' ? null : $group2,
'aggregate' => (int) $aggregate->get(0)->aggregate, 'seconds' => (int) $aggregate->get(0)->aggregate,
'cost' => (int) $aggregate->get(0)->cost, 'cost' => (int) $aggregate->get(0)->cost,
]; ];
$group2ResponseSum += (int) $aggregate->get(0)->aggregate; $group2ResponseSum += (int) $aggregate->get(0)->aggregate;
@@ -241,8 +241,8 @@ class TimeEntryController extends Controller
/** @var string $group1Type */ /** @var string $group1Type */
$group1Response[] = [ $group1Response[] = [
'type' => $group1Type, 'type' => $group1Type,
'value' => $group1 === '' ? null : $group1, 'key' => $group1 === '' ? null : $group1,
'aggregate' => $group2ResponseSum, 'seconds' => $group2ResponseSum,
'cost' => $group2ResponseCost, 'cost' => $group2ResponseCost,
'grouped_data' => $group2Response, 'grouped_data' => $group2Response,
]; ];
@@ -259,7 +259,7 @@ class TimeEntryController extends Controller
return [ return [
'data' => [ 'data' => [
'grouped_data' => $group1Response, 'grouped_data' => $group1Response,
'aggregate' => $group1ResponseSum, 'seconds' => $group1ResponseSum,
'cost' => $group1ResponseCost, 'cost' => $group1ResponseCost,
], ],
]; ];

View File

@@ -110,18 +110,18 @@ class TimeEntryAggregateRequest extends FormRequest
return $builder->visibleByUser(Auth::user()); return $builder->visibleByUser(Auth::user());
}), }),
], ],
// Filter only time entries that have a start date before (not including) the given date (example: 2021-12-31) // Filter only time entries that have a start date before the given timestamp in UTC (example: 2021-01-01T00:00:00Z)
'before' => [ 'before' => [
'nullable', 'nullable',
'string', 'string',
'date_format:Y-m-d\TH:i:s\Z', 'date_format:Y-m-d\TH:i:s\Z',
'before:after',
], ],
// Filter only time entries that have a start date after (not including) the given date (example: 2021-12-31) // Filter only time entries that have a start date after the given timestamp in UTC (example: 2021-01-01T00:00:00Z)
'after' => [ 'after' => [
'nullable', 'nullable',
'string', 'string',
'date_format:Y-m-d\TH:i:s\Z', 'date_format:Y-m-d\TH:i:s\Z',
'before:before',
], ],
// Filter by active status (active means has no end date, is still running) // Filter by active status (active means has no end date, is still running)
'active' => [ 'active' => [

View File

@@ -89,18 +89,18 @@ class TimeEntryIndexRequest extends FormRequest
return $builder->visibleByUser(Auth::user()); return $builder->visibleByUser(Auth::user());
}), }),
], ],
// Filter only time entries that have a start date before (not including) the given date (example: 2021-12-31) // Filter only time entries that have a start date before the given timestamp in UTC (example: 2021-01-01T00:00:00Z)
'before' => [ 'before' => [
'nullable', 'nullable',
'string', 'string',
'date_format:Y-m-d\TH:i:s\Z', 'date_format:Y-m-d\TH:i:s\Z',
'before:after',
], ],
// Filter only time entries that have a start date after (not including) the given date (example: 2021-12-31) // Filter only time entries that have a start date after the given timestamp in UTC (example: 2021-01-01T00:00:00Z)
'after' => [ 'after' => [
'nullable', 'nullable',
'string', 'string',
'date_format:Y-m-d\TH:i:s\Z', 'date_format:Y-m-d\TH:i:s\Z',
'before:before',
], ],
// Filter by active status (active means has no end date, is still running) // Filter by active status (active means has no end date, is still running)
'active' => [ 'active' => [