Removed N+1 query that came in with the tooltip pull request.

Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-05-04 18:59:42 +02:00
parent 26b581e904
commit dc0c845793

View File

@@ -134,21 +134,17 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
prxyTarget.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ));
prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ));
final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId());
final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet();
final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet();
prxyTarget.setInstalledDistributionSet(installedDistributionSet);
prxyTarget.setAssignedDistributionSet(assignedDistributionSet);
if (installedDistributionSet != null) {
prxyTarget.setInstalledDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion(
installedDistributionSet.getName(), installedDistributionSet.getVersion()));
}
if (assignedDistributionSet != null) {
prxyTarget.setAssignedDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion(
assignedDistributionSet.getName(), assignedDistributionSet.getVersion()));
if (pinnedDistId == null) {
prxyTarget.setInstalledDistributionSet(null);
prxyTarget.setAssignedDistributionSet(null);
} else {
final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId());
final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet();
prxyTarget.setInstalledDistributionSet(installedDistributionSet);
final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet();
prxyTarget.setAssignedDistributionSet(assignedDistributionSet);
}
prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus());
prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery());
prxyTarget.setTargetInfo(targ.getTargetInfo());