Skip to content

Commit

Permalink
[fix] timesheet entries that fall on midnight were not included
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed May 2, 2024
1 parent 5a0a3fd commit 2e9db31
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
3 changes: 2 additions & 1 deletion app/Core/Middleware/RequestRateLimiter.php
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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;
}

Expand Down
17 changes: 16 additions & 1 deletion app/Domain/Timesheets/Services/Timesheets.php
Expand Up @@ -396,19 +396,34 @@ 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)) {
$timesheetGroups[$groupKey]["day" . $i]['hours'] += $timesheet['hours'];
$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'];
}
Expand Down
30 changes: 15 additions & 15 deletions 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",
Expand Down

0 comments on commit 2e9db31

Please sign in to comment.