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 de3f105 commit 66eba11
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions src/combination/ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ export const getCombinationIds = function ({ dimensions }) {
}))
}

export const getDimensionId = function (propName, { dimensions }) {
return dimensions[propName].id
}

export const getDimensionTitle = function (propName, { dimensions }) {
const { titleName } = DIMENSIONS.find(
(dimension) => dimension.propName === propName,
Expand Down
8 changes: 4 additions & 4 deletions src/combination/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import sortOn from 'sort-on'
import { getMean } from '../stats/sum.js'
import { groupBy } from '../utils/group.js'

import { getCombinationsIds, getDimensionId } from './ids.js'
import { getCombinationsIds } from './ids.js'

// Sort `result.combinations` based on their `stats.mean`.
// Combinations with the same dimension are grouped together in the sorting
Expand Down Expand Up @@ -34,7 +34,7 @@ const getDimension = function ({ dimension: { propName } }) {
// Retrieve a function used to compare combinations for a specific dimension
const getSortFunction = function (dimension, combinations) {
const meansOfMeans = mapObj(
groupBy(combinations, getDimensionId.bind(undefined, dimension)),
groupBy(combinations, ({ dimensions }) => dimensions[dimension].id),
getMeanOfMeans,
)
return getCombinationOrder.bind(undefined, dimension, meansOfMeans)
Expand All @@ -57,7 +57,7 @@ const isDefined = function (mean) {
return mean !== undefined
}

const getCombinationOrder = function (dimension, meansOfMeans, combination) {
const id = getDimensionId(dimension, combination)
const getCombinationOrder = function (dimension, meansOfMeans, { dimensions }) {
const { id } = dimensions[dimension]
return meansOfMeans[id]
}

0 comments on commit 66eba11

Please sign in to comment.