-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(run): add ability to highlight param difference
This will add ability to highlight parameters difference relative clicked result row Signed-off-by: Danil Kostromin <[email protected]>
- Loading branch information
Danil Kostromin
committed
Feb 22, 2024
1 parent
3475b01
commit b75d295
Showing
5 changed files
with
189 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
export function calculateGroupSize( | ||
dataset: string[][], | ||
maxMismatchCount: number | ||
) { | ||
const referenceSet = dataset[0]; | ||
const referenceMap = new Map( | ||
Array.from(referenceSet, (item) => item.split('=')) as [string, string][] | ||
); | ||
|
||
let groupSize = 1; | ||
|
||
for (let i = 1; i < dataset.length; i++) { | ||
const currentSet = dataset[i]; | ||
const currentSetMap = new Map( | ||
Array.from(currentSet, (item) => item.split('=')) as [string, string][] | ||
); | ||
|
||
let mismatchCount = 0; | ||
|
||
for (const [key, value] of referenceMap) { | ||
if (currentSetMap.get(key) !== value) { | ||
mismatchCount++; | ||
if (mismatchCount >= maxMismatchCount) { | ||
groupSize = i; | ||
return groupSize; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return groupSize; | ||
} | ||
|
||
type DiffValue = { | ||
value: string; | ||
isDifferent?: boolean; | ||
}; | ||
|
||
export function highlightDifferences( | ||
dataset: string[][], | ||
referenceSet: string[] | ||
): DiffValue[][] { | ||
const PARAMETER_DELIMITER = '='; | ||
|
||
const highlightedDataset = []; | ||
|
||
const referenceMap = new Map<string, string>( | ||
Array.from(referenceSet, (item) => item.split(PARAMETER_DELIMITER)) as [ | ||
string, | ||
string | ||
][] | ||
); | ||
|
||
for (let i = 0; i < dataset.length; i++) { | ||
const currentSet = dataset[i]; | ||
const currentSetMap = new Map<string, string>( | ||
Array.from(currentSet, (item) => item.split(PARAMETER_DELIMITER)) as [ | ||
string, | ||
string | ||
][] | ||
); | ||
const highlightedSet: DiffValue[] = []; | ||
|
||
for (let j = 0; j < referenceSet.length; j++) { | ||
const referenceKeyValue = referenceSet[j].split(PARAMETER_DELIMITER); | ||
const currentKeyValue = currentSet[j].split(PARAMETER_DELIMITER); | ||
|
||
if ( | ||
referenceMap.get(referenceKeyValue[0]) !== | ||
currentSetMap.get(currentKeyValue[0]) | ||
) { | ||
highlightedSet.push({ value: currentSet[j], isDifferent: true }); | ||
} else { | ||
highlightedSet.push({ value: currentSet[j] }); | ||
} | ||
} | ||
|
||
highlightedDataset.push(highlightedSet); | ||
} | ||
|
||
return highlightedDataset; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters