From 41551b770f5ee65089121208d0737b6231e4a3f9 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Mon, 23 Feb 2026 12:15:24 +0100 Subject: [PATCH 1/3] Fix invalid calculation of task duration --- CHANGELOG.md | 6 ++++++ src/Command/TaskLogCommand.php | 2 +- src/Duration/DurationCalculator.php | 2 +- src/Entity/TaskRun.php | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c04db2..b71023b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +3.1.1 +===== + +* (bug) Fix invalid task run duration calculation. + + 3.1.0 ===== diff --git a/src/Command/TaskLogCommand.php b/src/Command/TaskLogCommand.php index fc9438e..346c72c 100644 --- a/src/Command/TaskLogCommand.php +++ b/src/Command/TaskLogCommand.php @@ -246,7 +246,7 @@ private function showList (TorrStyle $io, int $limit) : void } /** - * + * @param float $value The duration in nanoseconds */ private function formatDuration (float $value) : string { diff --git a/src/Duration/DurationCalculator.php b/src/Duration/DurationCalculator.php index 92d3494..c22d4e8 100644 --- a/src/Duration/DurationCalculator.php +++ b/src/Duration/DurationCalculator.php @@ -20,6 +20,6 @@ public function calculateDuration (\DateTimeImmutable $start, \DateTimeImmutable + $diff->s + $diff->f; - return $seconds / 1e9; + return $seconds * 1e9; } } diff --git a/src/Entity/TaskRun.php b/src/Entity/TaskRun.php index 6aa7ec9..88be30f 100644 --- a/src/Entity/TaskRun.php +++ b/src/Entity/TaskRun.php @@ -37,7 +37,7 @@ class TaskRun public private(set) \DateTimeImmutable $timeStarted; /** - * + * The duration of the run in nanoseconds */ #[ORM\Column(type: Types::FLOAT, nullable: true)] public private(set) ?float $duration = null; From 746ad0c87c8a2b0a75fd93a76bd04c27d24595d6 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Mon, 23 Feb 2026 12:26:39 +0100 Subject: [PATCH 2/3] Fix invalid tests --- tests/Duration/DurationCalculatorTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Duration/DurationCalculatorTest.php b/tests/Duration/DurationCalculatorTest.php index eb63f6c..0d07c23 100644 --- a/tests/Duration/DurationCalculatorTest.php +++ b/tests/Duration/DurationCalculatorTest.php @@ -19,25 +19,25 @@ public static function provideCalculation () : iterable yield "hours-minutes-seconds-microseconds" => [ "2020-01-01 00:00:00.000000", "2020-01-01 01:02:03.123456", - (3600 + 120 + 3.123456) / 1e9, + (3600 + 120 + 3.123456) * 1e9, ]; yield "years" => [ "2021-01-01 00:00:00.000000", "2022-01-01 00:00:00.000000", - (365 * 24 * 60 * 60) / 1e9, + (365 * 24 * 60 * 60) * 1e9, ]; yield "months" => [ "2021-01-01 00:00:00.000000", "2021-02-01 00:00:00.000000", - (31 * 24 * 60 * 60) / 1e9, + (31 * 24 * 60 * 60) * 1e9, ]; yield "days" => [ "2021-01-01 00:00:00.000000", "2021-01-04 00:00:00.000000", - (3 * 24 * 60 * 60) / 1e9, + (3 * 24 * 60 * 60) * 1e9, ]; } From 3e941ba3dafb904ec958667a313b9bf9dd6a985b Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Mon, 23 Feb 2026 12:29:28 +0100 Subject: [PATCH 3/3] Bump dependencies --- composer.json | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index a2f046c..627262a 100644 --- a/composer.json +++ b/composer.json @@ -12,31 +12,32 @@ "homepage": "https://github.com/21TORR/TaskManagerBundle", "require": { "php": ">= 8.4", - "21torr/bundle-helpers": "^2.3", + "21torr/bundle-helpers": "^2.3.1", "21torr/cli": "^1.2.3", - "21torr/hosting": "^4.0", - "21torr/snail": "^1.0.0", - "doctrine/doctrine-bundle": "^2.14", - "doctrine/orm": "^3.3", - "dragonmantank/cron-expression": "^3.4", + "21torr/hosting": "^4.1.1", + "21torr/snail": "^1.0.1", + "doctrine/doctrine-bundle": "^2.18", + "doctrine/orm": "^3.6", + "dragonmantank/cron-expression": "^3.6", "psr/log": "^3.0", - "symfony/clock": "^7.2", - "symfony/config": "^7.2", - "symfony/console": "^7.2", - "symfony/dependency-injection": "^7.2", + "symfony/clock": "^7.4 || ^8.0", + "symfony/config": "^7.4 || ^8.0", + "symfony/console": "^7.4 || ^8.0", + "symfony/dependency-injection": "^7.4 || ^8.0", "symfony/event-dispatcher": "^7.3", - "symfony/http-kernel": "^7.2", - "symfony/messenger": "^7.2", - "symfony/scheduler": "^7.2", - "symfony/string": "^7.2", - "symfony/uid": "^7.2" + "symfony/http-kernel": "^7.4 || ^8.0", + "symfony/lock": "^7.4 || ^8.0", + "symfony/messenger": "^7.4 || ^8.0", + "symfony/scheduler": "^7.4 || ^8.0", + "symfony/string": "^7.4 || ^8.0", + "symfony/uid": "^7.4 || ^8.0" }, "require-dev": { - "21torr/janus": "^2.0.0", - "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^12.2.5", + "21torr/janus": "^2.0.3", + "bamarni/composer-bin-plugin": "^1.9.1", + "phpunit/phpunit": "^13.0.5", "roave/security-advisories": "dev-latest", - "symfony/translation-contracts": "^3.6" + "symfony/translation-contracts": "^3.6.1" }, "autoload": { "psr-4": {