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.setCreatedByUser(UserDetailsFormatter.loadAndFormatCreatedBy(targ));
prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ)); prxyTarget.setModifiedByUser(UserDetailsFormatter.loadAndFormatLastModifiedBy(targ));
final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId()); if (pinnedDistId == null) {
final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet(); prxyTarget.setInstalledDistributionSet(null);
final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet(); prxyTarget.setAssignedDistributionSet(null);
} else {
prxyTarget.setInstalledDistributionSet(installedDistributionSet); final Target target = getTargetManagement().findTargetByControllerIDWithDetails(targ.getControllerId());
prxyTarget.setAssignedDistributionSet(assignedDistributionSet); final DistributionSet installedDistributionSet = target.getTargetInfo().getInstalledDistributionSet();
prxyTarget.setInstalledDistributionSet(installedDistributionSet);
if (installedDistributionSet != null) { final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet();
prxyTarget.setInstalledDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion( prxyTarget.setAssignedDistributionSet(assignedDistributionSet);
installedDistributionSet.getName(), installedDistributionSet.getVersion()));
}
if (assignedDistributionSet != null) {
prxyTarget.setAssignedDistNameVersion(HawkbitCommonUtil.getFormattedNameVersion(
assignedDistributionSet.getName(), assignedDistributionSet.getVersion()));
} }
prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus()); prxyTarget.setUpdateStatus(targ.getTargetInfo().getUpdateStatus());
prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery()); prxyTarget.setLastTargetQuery(targ.getTargetInfo().getLastTargetQuery());
prxyTarget.setTargetInfo(targ.getTargetInfo()); prxyTarget.setTargetInfo(targ.getTargetInfo());