Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 12, 2021
1 parent 2ba8831 commit 68e41ba
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/report/normalize/titles_pad.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DIMENSIONS } from '../../combination/dimensions.js'
import { getCombinationsIds } from '../../combination/ids.js'
import { groupBy } from '../../utils/group.js'

// Add:
// - `combination.task|runner|systemTitlePadded`: like
Expand All @@ -11,23 +12,29 @@ export const padTitles = function (combinations) {
}

const getUniqueTitleNames = function (combinations) {
const titleNames = DIMENSIONS.map(getTitleName).filter((titleName) =>
shouldShowProp(titleName, combinations),
const combinationsIds = getCombinationsIds(combinations)
const titleNames = Object.entries(
groupBy(combinationsIds, getDimensionTitleName),
)
.filter(shouldShowProp)
.map(getTitleName)
return titleNames.length === 0 ? DEFAULT_TITLE_NAMES : titleNames
}

const getTitleName = function ({ titleName }) {
const getDimensionTitleName = function ({ dimension: { titleName } }) {
return titleName
}

const DEFAULT_TITLE_NAMES = ['taskTitle']
const shouldShowProp = function ([, titleNames]) {
return titleNames.length !== 1
}

const shouldShowProp = function (titleName, combinations) {
const titles = combinations.map((combination) => combination[titleName])
return [...new Set(titles)].length !== 1
const getTitleName = function ([titleName]) {
return titleName
}

const DEFAULT_TITLE_NAMES = ['taskTitle']

const getPaddings = function (combinations, titleNames) {
return titleNames.map((titleName) => getPadding(combinations, titleName))
}
Expand Down

0 comments on commit 68e41ba

Please sign in to comment.