mirror of
https://github.com/ansible/awx.git
synced 2026-01-17 12:41:19 -03:30
Move check to outer scope for great performance
This commit is contained in:
parent
63b7ec8b67
commit
dae25b7123
@ -20,6 +20,11 @@ export function compareFacts(module, facts) {
|
||||
return _(leftToRight)
|
||||
.concat(rightToLeft)
|
||||
.unique('displayKeyPath')
|
||||
.thru(function(result) {
|
||||
return { factData: result,
|
||||
isNestedDisplay: _.isUndefined(module.factTemplate)
|
||||
};
|
||||
})
|
||||
.value();
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ import stringFilters from 'tower/shared/string-filters/main';
|
||||
var $injector = angular.injector(['ng', stringFilters.name]);
|
||||
var $interpolate = $injector.get('$interpolate');
|
||||
|
||||
function parseFactTemplate(factTemplate, fact) {
|
||||
function getFactTemplate(factTemplate, fact) {
|
||||
if (_.isFunction(factTemplate)) {
|
||||
return factTemplate(fact);
|
||||
} else {
|
||||
@ -40,11 +40,11 @@ function slotFactValues(basisPosition, basisValue, comparatorValue) {
|
||||
export default
|
||||
function flatCompare(basisFacts, comparatorFacts, nameKey, compareKeys, factTemplate) {
|
||||
|
||||
|
||||
return basisFacts.reduce(function(arr, basisFact) {
|
||||
var searcher = {};
|
||||
searcher[nameKey] = basisFact[nameKey];
|
||||
|
||||
var isNestedDisplay = false;
|
||||
var basisTemplate, comparatorTemplate, slottedValues, basisValue, comparatorValue;
|
||||
|
||||
var matchingFact = _.where(comparatorFacts, searcher);
|
||||
@ -54,26 +54,24 @@ export default
|
||||
|
||||
if (!_.isUndefined(factTemplate)) {
|
||||
|
||||
basisTemplate = parseFactTemplate(factTemplate, basisFact);
|
||||
basisTemplate = getFactTemplate(factTemplate, basisFact);
|
||||
|
||||
basisValue = renderFactTemplate(basisTemplate, basisFact);
|
||||
slottedValues = slotFactValues(basisFacts.position, basisValue, 'absent');
|
||||
|
||||
diffs =
|
||||
{ keyName: basisFact[nameKey],
|
||||
isNestedDisplay: false,
|
||||
value1: slottedValues.left,
|
||||
value2: slottedValues.right
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
isNestedDisplay = true;
|
||||
diffs =
|
||||
_.map(basisFact, function(value, key) {
|
||||
var slottedValues = slotFactValues(basisFacts.position, value, 'absent');
|
||||
|
||||
return { keyName: key,
|
||||
return { keyName: key,
|
||||
value1: slottedValues.left,
|
||||
value1IsAbsent: slottedValues.left === 'absent',
|
||||
value2: slottedValues.right,
|
||||
@ -87,8 +85,8 @@ export default
|
||||
|
||||
if (!_.isUndefined(factTemplate)) {
|
||||
|
||||
basisTemplate = parseFactTemplate(factTemplate, basisFact);
|
||||
comparatorTemplate = parseFactTemplate(factTemplate, matchingFact);
|
||||
basisTemplate = getFactTemplate(factTemplate, basisFact);
|
||||
comparatorTemplate = getFactTemplate(factTemplate, matchingFact);
|
||||
|
||||
basisValue = renderFactTemplate(basisTemplate, basisFact);
|
||||
comparatorValue = renderFactTemplate(comparatorTemplate, matchingFact);
|
||||
@ -99,7 +97,6 @@ export default
|
||||
|
||||
diffs =
|
||||
{ keyName: basisFact[nameKey],
|
||||
isNestedDisplay: false,
|
||||
value1: slottedValues.left,
|
||||
value2: slottedValues.right
|
||||
};
|
||||
@ -108,8 +105,6 @@ export default
|
||||
|
||||
} else {
|
||||
|
||||
isNestedDisplay = true;
|
||||
|
||||
diffs = _(compareKeys)
|
||||
.map(function(key) {
|
||||
var slottedValues = slotFactValues(basisFacts.position,
|
||||
@ -131,7 +126,6 @@ export default
|
||||
|
||||
var descriptor =
|
||||
{ displayKeyPath: basisFact[nameKey],
|
||||
isNestedDisplay: isNestedDisplay,
|
||||
nestingLevel: 0,
|
||||
facts: diffs
|
||||
};
|
||||
|
||||
@ -12,8 +12,6 @@ export default
|
||||
function(factScanDataService, getModuleOptions, resolveVersions, _) {
|
||||
return function(hostIds, moduleName, leftDate, rightDate) {
|
||||
|
||||
var moduleOptions;
|
||||
|
||||
if (hostIds.length === 1) {
|
||||
hostIds = hostIds.concat(hostIds[0]);
|
||||
}
|
||||
@ -49,7 +47,7 @@ export default
|
||||
}
|
||||
})
|
||||
.thenAll(function(hostFacts) {
|
||||
return [moduleOptions, hostFacts];
|
||||
return hostFacts;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@ -62,8 +62,7 @@ function controller($rootScope,
|
||||
activeModule.name,
|
||||
leftRange,
|
||||
rightRange)
|
||||
.then(function(factDataAndModules) {
|
||||
var responses = factDataAndModules[1];
|
||||
.then(function(responses) {
|
||||
var data = _.pluck(responses, 'fact');
|
||||
|
||||
$scope.leftScanDate = moment(responses[0].timestamp);
|
||||
@ -126,7 +125,8 @@ function controller($rootScope,
|
||||
// Clear out any errors from the previous run...
|
||||
$scope.error = null;
|
||||
|
||||
$scope.factData = info;
|
||||
$scope.factData = info.factData;
|
||||
$scope.isNestedDisplay = info.isNestedDisplay;
|
||||
|
||||
return info;
|
||||
|
||||
|
||||
@ -54,52 +54,57 @@
|
||||
<span class="FactDataTableHeading-date">{{rightScanDate|longDate}}</span>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="FactDataTable-factGroup FactDataGroup" ng-repeat="group in factData | orderBy: 'displayKeyPath'">
|
||||
<div class="FactDataTable-row" ng-if="!group.isNestedDisplay">
|
||||
<div ng-if="!isNestedDisplay">
|
||||
<div class="FactDataTable-row" ng-repeat="group in factData | orderBy: 'displayKeyPath'">
|
||||
<p class="FactDataTable-column">{{group.facts.keyName}}</p>
|
||||
<p class="FactDataTable-column">{{group.facts.value1}}</p>
|
||||
<p class="FactDataTable-column">{{group.facts.value2}}</p>
|
||||
</div>
|
||||
<div class="FactDataTable-row FactDataGroup-headings" ng-switch="group.nestingLevel" ng-if="group.displayKeyPath && group.isNestedDisplay">
|
||||
<h2 class="FactDataTable-column FactDataTable-column--full FactDataGroup-header" ng-switch-when="0">
|
||||
{{group.displayKeyPath}}
|
||||
</h2>
|
||||
<h3 class="FactDataTable-column FactDataTable-column--full" ng-switch-when="1">
|
||||
{{group.displayKeyPath}}
|
||||
</h3>
|
||||
<h4 class="FactDataTable-column FactDataTable-column--full" ng-switch-when="2">
|
||||
{{group.displayKeyPath}}
|
||||
</h4>
|
||||
<h5 class="FactDataTable-column FactDataTable-column--full" ng-switch-when="3">
|
||||
{{group.displayKeyPath}}
|
||||
</h5>
|
||||
</div>
|
||||
<div class="FactDataGroup-facts" data-facts="{{group.facts}}">
|
||||
<div class="FactDataTable-arrayGroup" ng-if="group.isFactArray" ng-repeat="arrayGroup in group.facts" data-array-group="{{arrayGroup}}">
|
||||
<div class="FactDataTable-row FactDatum" ng-class="{'FactDatum--divergent': fact.isDivergent }" ng-repeat="fact in arrayGroup" data-fact="{{fact}}">
|
||||
<p class="FactDatum-keyName FactDataTable-column">
|
||||
</div>
|
||||
<div ng-if="isNestedDisplay">
|
||||
|
||||
<div class="FactDataTable-factGroup FactDataGroup" ng-repeat="group in factData | orderBy: 'displayKeyPath'">
|
||||
|
||||
<div class="FactDataTable-row FactDataGroup-headings" ng-switch="group.nestingLevel">
|
||||
<h2 class="FactDataTable-column FactDataTable-column--full FactDataGroup-header" ng-switch-when="0">
|
||||
{{group.displayKeyPath}}
|
||||
</h2>
|
||||
<h3 class="FactDataTable-column FactDataTable-column--full" ng-switch-when="1">
|
||||
{{group.displayKeyPath}}
|
||||
</h3>
|
||||
<h4 class="FactDataTable-column FactDataTable-column--full" ng-switch-when="2">
|
||||
{{group.displayKeyPath}}
|
||||
</h4>
|
||||
<h5 class="FactDataTable-column FactDataTable-column--full" ng-switch-when="3">
|
||||
{{group.displayKeyPath}}
|
||||
</h5>
|
||||
</div>
|
||||
<div class="FactDataGroup-facts" data-facts="{{group.facts}}">
|
||||
<div class="FactDataTable-arrayGroup" ng-if="group.isFactArray" ng-repeat="arrayGroup in group.facts" data-array-group="{{arrayGroup}}">
|
||||
<div class="FactDataTable-row FactDatum" ng-class="{'FactDatum--divergent': fact.isDivergent }" ng-repeat="fact in arrayGroup" data-fact="{{fact}}">
|
||||
<p class="FactDatum-keyName FactDataTable-column">
|
||||
{{fact.keyName}}
|
||||
</p>
|
||||
<p class="FactDatum-value FactDataTable-column" style="word-break: break-all">
|
||||
</p>
|
||||
<p class="FactDatum-value FactDataTable-column" style="word-break: break-all">
|
||||
{{fact.value1}}
|
||||
</p>
|
||||
<p class="FactDatum-value FactDataTable-column" style="word-break: break-all">
|
||||
</p>
|
||||
<p class="FactDatum-value FactDataTable-column" style="word-break: break-all">
|
||||
{{fact.value2}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="FactDataTable-row FactDatum" ng-class="{'FactDatum--divergent': fact.isDivergent }" ng-repeat="fact in group.facts" ng-unless="group.isFactArray" data-fact="{{fact}}">
|
||||
<p class="FactDataTable-column FactDatum-keyName">
|
||||
{{fact.keyName}}
|
||||
</p>
|
||||
<p class="FactDataTable-column FactDatum-value" style="word-break: break-all">
|
||||
{{fact.value1}}
|
||||
</p>
|
||||
<p class="FactDataTable-column FactDatum-value" style="word-break: break-all">
|
||||
{{fact.value2}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="FactDataTable-row FactDatum" ng-class="{'FactDatum--divergent': fact.isDivergent }" ng-repeat="fact in group.facts" ng-unless="group.isFactArray" data-fact="{{fact}}">
|
||||
<p class="FactDataTable-column FactDatum-keyName">
|
||||
{{fact.keyName}}
|
||||
</p>
|
||||
<p class="FactDataTable-column FactDatum-value" style="word-break: break-all">
|
||||
{{fact.value1}}
|
||||
</p>
|
||||
<p class="FactDataTable-column FactDatum-value" style="word-break: break-all">
|
||||
{{fact.value2}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user