From 2e9db313fee6c5380ebe04e34567cc6c97485103 Mon Sep 17 00:00:00 2001 From: Marcel Folaron Date: Thu, 2 May 2024 10:45:00 -0400 Subject: [PATCH] [fix] timesheet entries that fall on midnight were not included --- app/Core/Middleware/RequestRateLimiter.php | 3 +- app/Domain/Timesheets/Services/Timesheets.php | 17 ++++++++++- public/dist/mix-manifest.json | 30 +++++++++---------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/app/Core/Middleware/RequestRateLimiter.php b/app/Core/Middleware/RequestRateLimiter.php index e475eafb0..f81c673e8 100644 --- a/app/Core/Middleware/RequestRateLimiter.php +++ b/app/Core/Middleware/RequestRateLimiter.php @@ -10,6 +10,7 @@ use Leantime\Core\Frontcontroller; use Leantime\Core\IncomingRequest; use Leantime\Core\Middleware\Request; +use Leantime\Domain\Api\Services\Api; use Symfony\Component\HttpFoundation\Response; /** @@ -55,7 +56,7 @@ public function handle(IncomingRequest $request, Closure $next): Response //API Routes Limit if ($request instanceof ApiRequest) { $apiKey = ""; - $key = app()->make(ApiRequest::class)->getAPIKeyUser($apiKey); + $key = app()->make(Api::class)->getAPIKeyUser($apiKey); $limit = 10; } diff --git a/app/Domain/Timesheets/Services/Timesheets.php b/app/Domain/Timesheets/Services/Timesheets.php index 47d32616f..379999830 100644 --- a/app/Domain/Timesheets/Services/Timesheets.php +++ b/app/Domain/Timesheets/Services/Timesheets.php @@ -396,7 +396,7 @@ public function getWeeklyTimesheets(int $projectId, CarbonInterface $fromDate, i // will be different since it is based on start of the day 00:00:00 in the current users timezone and then // stored as UTC timezone shoifted value in the db. // If the value is not exact but falls within the time period we're adding a new row - for ($i = 1; $i < 8; $i++) { + /*for ($i = 1; $i < 8; $i++) { $start = $timesheetGroups[$groupKey]["day" . $i]["start"]; $end = $timesheetGroups[$groupKey]["day" . $i]["end"]; if ($currentWorkDate->gte($start) && $currentWorkDate->lte($end)) { @@ -404,11 +404,26 @@ public function getWeeklyTimesheets(int $projectId, CarbonInterface $fromDate, i $timesheetGroups[$groupKey]["day" . $i]['actualWorkDate'] = $currentWorkDate; $timesheetGroups[$groupKey]["day" . $i]['description'] = $timesheet['description']; + // No need to check further, we found what we came for + break; + } + }*/ + + for ($i = 1; $i < 8; $i++) { + + if ($timesheetGroups[$groupKey]["day" . $i]['actualWorkDate'] == $currentWorkDate) { + + $timesheetGroups[$groupKey]["day" . $i]['hours'] += $timesheet['hours']; + $timesheetGroups[$groupKey]["day" . $i]['description'] = $timesheet['description']; + // No need to check further, we found what we came for break; } } + + + // Add to rowsum $timesheetGroups[$groupKey]["rowSum"] += $timesheet['hours']; } diff --git a/public/dist/mix-manifest.json b/public/dist/mix-manifest.json index 867c74e0c..7a09c8817 100644 --- a/public/dist/mix-manifest.json +++ b/public/dist/mix-manifest.json @@ -1,19 +1,19 @@ { - "/js/compiled-htmx.3.1.2.min.js": "/js/compiled-htmx.3.1.2.min.js", - "/js/compiled-htmx-headSupport.3.1.2.min.js": "/js/compiled-htmx-headSupport.3.1.2.min.js", - "/css/main.3.1.2.min.css": "/css/main.3.1.2.min.css", - "/css/editor.3.1.2.min.css": "/css/editor.3.1.2.min.css", - "/css/app.3.1.2.min.css": "/css/app.3.1.2.min.css", - "/js/compiled-footer.3.1.2.min.js": "/js/compiled-footer.3.1.2.min.js", - "/js/compiled-app.3.1.2.min.js": "/js/compiled-app.3.1.2.min.js", - "/js/compiled-frameworks.3.1.2.min.js": "/js/compiled-frameworks.3.1.2.min.js", - "/js/compiled-framework-plugins.3.1.2.min.js": "/js/compiled-framework-plugins.3.1.2.min.js", - "/js/compiled-global-component.3.1.2.min.js": "/js/compiled-global-component.3.1.2.min.js", - "/js/compiled-calendar-component.3.1.2.min.js": "/js/compiled-calendar-component.3.1.2.min.js", - "/js/compiled-table-component.3.1.2.min.js": "/js/compiled-table-component.3.1.2.min.js", - "/js/compiled-editor-component.3.1.2.min.js": "/js/compiled-editor-component.3.1.2.min.js", - "/js/compiled-gantt-component.3.1.2.min.js": "/js/compiled-gantt-component.3.1.2.min.js", - "/js/compiled-chart-component.3.1.2.min.js": "/js/compiled-chart-component.3.1.2.min.js", + "/js/compiled-htmx.3.1.3.min.js": "/js/compiled-htmx.3.1.3.min.js", + "/js/compiled-htmx-headSupport.3.1.3.min.js": "/js/compiled-htmx-headSupport.3.1.3.min.js", + "/css/main.3.1.3.min.css": "/css/main.3.1.3.min.css", + "/css/editor.3.1.3.min.css": "/css/editor.3.1.3.min.css", + "/css/app.3.1.3.min.css": "/css/app.3.1.3.min.css", + "/js/compiled-footer.3.1.3.min.js": "/js/compiled-footer.3.1.3.min.js", + "/js/compiled-app.3.1.3.min.js": "/js/compiled-app.3.1.3.min.js", + "/js/compiled-frameworks.3.1.3.min.js": "/js/compiled-frameworks.3.1.3.min.js", + "/js/compiled-framework-plugins.3.1.3.min.js": "/js/compiled-framework-plugins.3.1.3.min.js", + "/js/compiled-global-component.3.1.3.min.js": "/js/compiled-global-component.3.1.3.min.js", + "/js/compiled-calendar-component.3.1.3.min.js": "/js/compiled-calendar-component.3.1.3.min.js", + "/js/compiled-table-component.3.1.3.min.js": "/js/compiled-table-component.3.1.3.min.js", + "/js/compiled-editor-component.3.1.3.min.js": "/js/compiled-editor-component.3.1.3.min.js", + "/js/compiled-gantt-component.3.1.3.min.js": "/js/compiled-gantt-component.3.1.3.min.js", + "/js/compiled-chart-component.3.1.3.min.js": "/js/compiled-chart-component.3.1.3.min.js", "/images/03-1.png": "/images/03-1.png", "/images/32px.png": "/images/32px.png", "/images/40px.png": "/images/40px.png",