From a9a839a549fee63a7c83ca4d9d905a3b054ccb59 Mon Sep 17 00:00:00 2001 From: Joe Fiorini Date: Tue, 2 Jun 2015 13:06:30 -0400 Subject: [PATCH] Compare facts in both directions, not just one way --- awx/ui/static/js/system-tracking/compare-facts.js | 11 ++++++++++- .../static/js/system-tracking/compare-facts/flat.js | 5 +---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/awx/ui/static/js/system-tracking/compare-facts.js b/awx/ui/static/js/system-tracking/compare-facts.js index 1c57931da6..4941be51e3 100644 --- a/awx/ui/static/js/system-tracking/compare-facts.js +++ b/awx/ui/static/js/system-tracking/compare-facts.js @@ -11,6 +11,15 @@ export function compareFacts(module, facts) { if (module.displayType === 'nested') { return compareNestedFacts(facts); } else { - return compareFlatFacts(facts, module.nameKey, module.compareKey, module.factTemplate); + // For flat structures we compare left-to-right, then right-to-left to + // make sure we get a good comparison between both hosts + var compare = _.partialRight(compareFlatFacts, module.nameKey, module.compareKey, module.factTemplate); + var leftToRight = compare(facts[0], facts[1]); + var rightToLeft = compare(facts[1], facts[0]); + + return _(leftToRight) + .concat(rightToLeft) + .unique('displayKeyPath') + .value(); } } diff --git a/awx/ui/static/js/system-tracking/compare-facts/flat.js b/awx/ui/static/js/system-tracking/compare-facts/flat.js index e49f4e02b6..fa0e0f8b87 100644 --- a/awx/ui/static/js/system-tracking/compare-facts/flat.js +++ b/awx/ui/static/js/system-tracking/compare-facts/flat.js @@ -38,10 +38,7 @@ function slotFactValues(basisPosition, basisValue, comparatorValue) { } export default - function flatCompare(facts, nameKey, compareKeys, factTemplate) { - - var comparatorFacts = facts[0]; - var basisFacts = facts[1]; + function flatCompare(basisFacts, comparatorFacts, nameKey, compareKeys, factTemplate) { return basisFacts.reduce(function(arr, basisFact) { var searcher = {};