Skip to content

Commit 0852cd9

Browse files
author
jessevz
committed
Fixed copilot suggestions
1 parent 7499816 commit 0852cd9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/inc/apiv2/helper/taskExtraDetails.routes.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@ public function handleGet(Request $request, Response $response): Response {
3737
$this->preCommon($request);
3838

3939
$taskId = $request->getQueryParams()['task'];
40-
if ($taskId == null) {
40+
if ($taskId === null) {
4141
throw new HttpErrorException("No task query param has been provided");
4242
}
4343
$taskId = intval($taskId);
4444
if ($taskId === 0) {
4545
throw new HttpErrorException("No valid integer provided as task");
4646
}
47+
$task = Factory::getTaskFactory()->get($taskId);
48+
if ($task === null) {
49+
throw new HttpErrorException("No task found for provided task ID");
50+
}
4751

4852
$qF = new QueryFilter(Chunk::TASK_ID, $taskId, "=");
4953
$chunks = Factory::getChunkFactory()->filter([Factory::FILTER => $qF]);
@@ -70,9 +74,8 @@ public function handleGet(Request $request, Response $response): Response {
7074
$current = $c->getSolveTime();
7175
}
7276
}
73-
$task = Factory::getTaskFactory()->get($taskId);
7477
$keyspace = $task->getKeyspace();
75-
$estimatedTime = ($keyspace > 0) ? round($timeSpent / ($cProgress / $keyspace) - $timeSpent) : 0;
78+
$estimatedTime = ($keyspace > 0 && $cProgress > 0) ? round($timeSpent / ($cProgress / $keyspace) - $timeSpent) : 0;
7679
$responseObject = [
7780
"estimatedTime" => $estimatedTime,
7881
"timeSpent" => $timeSpent,
@@ -83,7 +86,7 @@ public function handleGet(Request $request, Response $response): Response {
8386
}
8487

8588
#[NoReturn] public function actionPost($data): object|array|null {
86-
assert(False, "TaskExtraDetails has no POST");
89+
assert(false, "TaskExtraDetails has no POST");
8790
}
8891

8992
static public function register($app): void {

0 commit comments

Comments
 (0)