Skip to content

Commit

Permalink
Merge pull request #2498 from Leantime/timesheetFixesForInvalidData
Browse files Browse the repository at this point in the history
Timesheet fixes for invalid data
  • Loading branch information
marcelfolaron committed May 2, 2024
2 parents 3458523 + fc6cf2f commit 281bb2d
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 44 deletions.
64 changes: 64 additions & 0 deletions .idea/leantime-oss.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/phpspec.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/phpunit.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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: 10 additions & 7 deletions app/Domain/Timesheets/Controllers/ShowMy.php
Expand Up @@ -137,13 +137,16 @@ public function saveTimeSheet(array $postData): void
"kind" => $kind,
);

try {
$this->timesheetService->upsertTime($ticketId, $values);
$this->tpl->setNotification("Timesheet saved successfully", "success", "save_timesheet");
} catch (\Exception $e) {
$this->tpl->setNotification("Error logging time: " . $e->getMessage(), "error", "save_timesheet");
error_log($e);
continue;
//This should not be the case since we set the input to disabled, but check anyways
if($timestamp !== "false" && $timestamp != false) {
try {
$this->timesheetService->upsertTime($ticketId, $values);
$this->tpl->setNotification("Timesheet saved successfully", "success", "save_timesheet");
} catch (\Exception $e) {
$this->tpl->setNotification("Error logging time: " . $e->getMessage(), "error", "save_timesheet");
error_log($e);
continue;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/Domain/Timesheets/Controllers/ShowMyList.php
Expand Up @@ -49,8 +49,8 @@ public function run(): Response
// The front end javascript is hardcode to start the week on mondays, so we use that here too.

//Get start of the week in current users timezone and then switch to UTC
$dateFrom = dtHelper()->userNow()->startOfMonth()->setToDbTimezone();
$dateTo = dtHelper()->userNow()->endOfMonth()->setToDbTimezone();
$dateFrom = dtHelper()->userNow()->startOfWeek(CarbonInterface::MONDAY)->setToDbTimezone();
$dateTo = dtHelper()->userNow()->endOfWeek()->setToDbTimezone();

if (!empty($_POST['dateFrom'])) {
$dateFrom = dtHelper()->parseUserDateTime($_POST['dateFrom'])->setToDbTimezone();
Expand Down

0 comments on commit 281bb2d

Please sign in to comment.