Skip to content

Commit 3f7111c

Browse files
authored
Merge pull request #48 from 21TORR/fix-duration
Fix duration calculation
2 parents 0046098 + 3e941ba commit 3f7111c

6 files changed

Lines changed: 33 additions & 26 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
3.1.1
2+
=====
3+
4+
* (bug) Fix invalid task run duration calculation.
5+
6+
17
3.1.0
28
=====
39

composer.json

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,32 @@
1212
"homepage": "https://github.com/21TORR/TaskManagerBundle",
1313
"require": {
1414
"php": ">= 8.4",
15-
"21torr/bundle-helpers": "^2.3",
15+
"21torr/bundle-helpers": "^2.3.1",
1616
"21torr/cli": "^1.2.3",
17-
"21torr/hosting": "^4.0",
18-
"21torr/snail": "^1.0.0",
19-
"doctrine/doctrine-bundle": "^2.14",
20-
"doctrine/orm": "^3.3",
21-
"dragonmantank/cron-expression": "^3.4",
17+
"21torr/hosting": "^4.1.1",
18+
"21torr/snail": "^1.0.1",
19+
"doctrine/doctrine-bundle": "^2.18",
20+
"doctrine/orm": "^3.6",
21+
"dragonmantank/cron-expression": "^3.6",
2222
"psr/log": "^3.0",
23-
"symfony/clock": "^7.2",
24-
"symfony/config": "^7.2",
25-
"symfony/console": "^7.2",
26-
"symfony/dependency-injection": "^7.2",
23+
"symfony/clock": "^7.4 || ^8.0",
24+
"symfony/config": "^7.4 || ^8.0",
25+
"symfony/console": "^7.4 || ^8.0",
26+
"symfony/dependency-injection": "^7.4 || ^8.0",
2727
"symfony/event-dispatcher": "^7.3",
28-
"symfony/http-kernel": "^7.2",
29-
"symfony/messenger": "^7.2",
30-
"symfony/scheduler": "^7.2",
31-
"symfony/string": "^7.2",
32-
"symfony/uid": "^7.2"
28+
"symfony/http-kernel": "^7.4 || ^8.0",
29+
"symfony/lock": "^7.4 || ^8.0",
30+
"symfony/messenger": "^7.4 || ^8.0",
31+
"symfony/scheduler": "^7.4 || ^8.0",
32+
"symfony/string": "^7.4 || ^8.0",
33+
"symfony/uid": "^7.4 || ^8.0"
3334
},
3435
"require-dev": {
35-
"21torr/janus": "^2.0.0",
36-
"bamarni/composer-bin-plugin": "^1.8.2",
37-
"phpunit/phpunit": "^12.2.5",
36+
"21torr/janus": "^2.0.3",
37+
"bamarni/composer-bin-plugin": "^1.9.1",
38+
"phpunit/phpunit": "^13.0.5",
3839
"roave/security-advisories": "dev-latest",
39-
"symfony/translation-contracts": "^3.6"
40+
"symfony/translation-contracts": "^3.6.1"
4041
},
4142
"autoload": {
4243
"psr-4": {

src/Command/TaskLogCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ private function showList (TorrStyle $io, int $limit) : void
246246
}
247247

248248
/**
249-
*
249+
* @param float $value The duration in nanoseconds
250250
*/
251251
private function formatDuration (float $value) : string
252252
{

src/Duration/DurationCalculator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public function calculateDuration (\DateTimeImmutable $start, \DateTimeImmutable
2020
+ $diff->s
2121
+ $diff->f;
2222

23-
return $seconds / 1e9;
23+
return $seconds * 1e9;
2424
}
2525
}

src/Entity/TaskRun.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TaskRun
3737
public private(set) \DateTimeImmutable $timeStarted;
3838

3939
/**
40-
*
40+
* The duration of the run in nanoseconds
4141
*/
4242
#[ORM\Column(type: Types::FLOAT, nullable: true)]
4343
public private(set) ?float $duration = null;

tests/Duration/DurationCalculatorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@ public static function provideCalculation () : iterable
1919
yield "hours-minutes-seconds-microseconds" => [
2020
"2020-01-01 00:00:00.000000",
2121
"2020-01-01 01:02:03.123456",
22-
(3600 + 120 + 3.123456) / 1e9,
22+
(3600 + 120 + 3.123456) * 1e9,
2323
];
2424

2525
yield "years" => [
2626
"2021-01-01 00:00:00.000000",
2727
"2022-01-01 00:00:00.000000",
28-
(365 * 24 * 60 * 60) / 1e9,
28+
(365 * 24 * 60 * 60) * 1e9,
2929
];
3030

3131
yield "months" => [
3232
"2021-01-01 00:00:00.000000",
3333
"2021-02-01 00:00:00.000000",
34-
(31 * 24 * 60 * 60) / 1e9,
34+
(31 * 24 * 60 * 60) * 1e9,
3535
];
3636

3737
yield "days" => [
3838
"2021-01-01 00:00:00.000000",
3939
"2021-01-04 00:00:00.000000",
40-
(3 * 24 * 60 * 60) / 1e9,
40+
(3 * 24 * 60 * 60) * 1e9,
4141
];
4242
}
4343

0 commit comments

Comments
 (0)