-
Notifications
You must be signed in to change notification settings - Fork 249
Add aggregate field crackingTime to AgentAssignment #2329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
s3inlc
merged 12 commits into
master
from
2297-enhancement-add-crackingtime-on-agentassignment
Jul 15, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
18ce558
Add aggregate field crackingTime to AgentAssignment, consolidate with…
novasam23 5d310c9
Potential fix for pull request finding
novasam23 c0165aa
Potential fix for pull request finding
novasam23 16a7bfc
Potential fix for pull request finding
novasam23 5084081
Potential fix for pull request finding
novasam23 86d2c48
Potential fix for pull request finding
novasam23 2f6844e
Fix some issues with previous commit
novasam23 08dfb52
Bumping Node to version 22 in the OpenAPI Lint workflow due to errors…
novasam23 90bf52b
Reverting Node back to version 20 after changing it due to a wrong Co…
novasam23 f23fd34
Merge remote-tracking branch 'origin/master' into 2297-enhancement-ad…
novasam23 2ea9cbf
Move aggregate cracking time from TaskUtils to AgentUtils, refactor o…
novasam23 6b358c5
Potential fix for pull request finding
novasam23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <?php | ||
|
|
||
| namespace Hashtopolis\inc\utils; | ||
|
|
||
| use Exception; | ||
| use Hashtopolis\dba\Factory; | ||
| use Hashtopolis\TestBase; | ||
|
|
||
| require_once(dirname(__FILE__) . '/../../TestBase.php'); | ||
|
|
||
| final class AgentUtilsTest extends TestBase { | ||
|
|
||
| protected function setUp(): void { | ||
| parent::setUp(); | ||
| } | ||
|
|
||
| /** | ||
| * Test cracking time aggregation for an agent on a task. | ||
| * | ||
| * @return void | ||
| * @throws Exception | ||
| */ | ||
| public function testCrackingTimeAggregation(): void { | ||
| $task = $this->createTaskHelper()["task"]; | ||
| $agent1 = $this->createAgent("test"); | ||
| $agent2 = $this->createAgent("test"); | ||
| $timeSpans = (array) [ | ||
| [1000, 2000, $agent1], | ||
| [3000, 5000, $agent2], | ||
| [3000, 8000, $agent1], | ||
| [8000, 10000, $agent1], | ||
| [15000, 20000, $agent1], | ||
| ]; | ||
|
|
||
| foreach ($timeSpans as [$start, $end, $agent]) { | ||
| $chunk = $this->createChunk($task, $agent, 4); | ||
| $chunk->setDispatchTime($start); | ||
| $chunk->setSolveTime($end); | ||
| Factory::getChunkFactory()->update($chunk); | ||
| } | ||
|
|
||
| // Calculate reference value via an interval merge algorithm | ||
| $totalEnd = $referenceSum = 0; | ||
| usort($timeSpans, fn($a, $b) => $a[0] <=> $b[0]); // Make sure time spans are sorted | ||
| foreach ($timeSpans as [$currentStart, $currentEnd, $agent]) { // Expects list to be sorted by time | ||
| if ($agent == $agent1) { | ||
| $referenceSum = $referenceSum + ($currentEnd - $currentStart) // Add current time span to running total | ||
| - max(0, $totalEnd - $currentStart) // Correct for potential overlapping when current start before previous end | ||
| + max(0, $totalEnd - $currentEnd); // Correct for potential overcorrection when current end before previous end | ||
| $totalEnd = max($totalEnd, $currentEnd); // Extend window if current end exceeds previous end | ||
| } | ||
| } | ||
|
|
||
| // Calculate aggregate cracking time via AgentUtils | ||
| $crackingTime = AgentUtils::getAggregateCrackingTime($agent1->getId(), $task->getId()); | ||
|
|
||
| $this->assertEquals($referenceSum, $crackingTime); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.