-
Notifications
You must be signed in to change notification settings - Fork 253
2391 bug filtering for active chunk on agent aggregate is not ideal #2430
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
02f06dd
fbf2c73
de0b032
656703b
ab689d7
6c9bfc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| use Hashtopolis\inc\apiv2\error\HttpError; | ||
| use Hashtopolis\inc\defines\DAgentStatsType; | ||
| use Hashtopolis\inc\defines\DConfig; | ||
| use Hashtopolis\inc\defines\DHashcatStatus; | ||
| use Hashtopolis\inc\defines\DLogEntry; | ||
| use Hashtopolis\inc\defines\DLogEntryIssuer; | ||
| use Hashtopolis\inc\defines\DNotificationObjectType; | ||
|
|
@@ -644,4 +645,24 @@ public static function getAggregateCracked(int $agentId, ?int $taskId = null): i | |
| $results = Factory::getChunkFactory()->multicolAggregationFilter([Factory::FILTER => array_filter([$qF1, $qF2])], [$agg1]); | ||
| return (int)($results[$agg1->getName()] ?? 0); | ||
| } | ||
|
|
||
| /** | ||
| * Get the active chunk being worked on by an agent or | ||
| * (if task ID is specified) by an agent on a specific task. | ||
| * | ||
| * @param int $agentId | ||
| * @param int|null $taskId | ||
| * @return Chunk|null | ||
| * @throws Exception | ||
| */ | ||
| public static function getActiveChunk(int $agentId, ?int $taskId = null): ?Chunk { | ||
| $qFs = []; | ||
| $qFs[] = new QueryFilter(Chunk::AGENT_ID, $agentId, "="); | ||
| $qFs[] = $taskId !== null ? new QueryFilter(Chunk::TASK_ID, $taskId, "=") : null; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line looks a bit like a code smell to me, this will add null to the qFs array when when taskId is null. But we dont really need that null value. I think it is better to use a normal if statement instead of a tenary to only add this to the qFs[] when taskId is not null and otherwise dont add anything
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see now that you filter the null value away later by doing array_filter(). Still for readability I think it is better to just do a normal if statement |
||
| $qFs[] = new QueryFilter(Chunk::STATE, DHashcatStatus::RUNNING, "="); | ||
| $qFs[] = new QueryFilter(Chunk::SOLVE_TIME, time() - SConfig::getInstance()->getVal(DConfig::CHUNK_TIMEOUT), ">"); | ||
| $qFs[] = new QueryFilter(Chunk::PROGRESS, 10000, "<"); | ||
| $oF = new OrderFilter(Chunk::SOLVE_TIME, "DESC"); | ||
| return Factory::getChunkFactory()->filter([Factory::FILTER => array_filter($qFs), Factory::ORDER => $oF], true); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.