Skip to content

Commit

Permalink
fix(GroupDynamic): fix count from PackageTarget (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
stonebuzz authored Feb 1, 2024
1 parent 1034acf commit cd63278
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
25 changes: 7 additions & 18 deletions src/Computer/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,25 +170,14 @@ public function showForm($id, array $options = [])

public function countDynamicItem()
{
/** @var object $DB */
global $DB;
$count = 0;

$params = [
'SELECT' => '*',
'FROM' => GroupDynamic::getTable(),
'WHERE' => ['plugin_deploy_computers_groups_id' => $this->fields['id']],
];

$iterator = $DB->request($params);
foreach ($iterator as $computergroup_dynamic) {
$params = unserialize($computergroup_dynamic['search']);
$computers_params["reset"] = true;
$search_params = Search::manageParams('Computer', $computers_params);
$data = Search::prepareDatasForSearch('Computer', $search_params);
Search::constructSQL($data);
Search::constructData($data, true);
$count += $data['data']['totalcount'];
$group = new GroupDynamic();
if (
$group->getFromDBByCrit([
'plugin_deploy_computers_groups_id' => $this->fields['id']
])
) {
$count = $group->countDynamicItems();
}

return $count;
Expand Down
1 change: 0 additions & 1 deletion src/Computer/GroupDynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public static function getSpecificValueToDisplay($field, $values, array $options
$computergroup_dynamic->getFromDB($values['id']);
$count = $computergroup_dynamic->countDynamicItems();
}
Toolbox::logDebug($count);
return ($count) ? $count : ' 0 ';

case '_virtual_dynamic_list':
Expand Down

0 comments on commit cd63278

Please sign in to comment.