Skip to content

Commit

Permalink
Fix new combinations ids
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Dec 19, 2021
1 parent bfbd63f commit 7958b8f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/combination/ids/namespace.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setArrayElement } from '../../utils/set.js'

import { getCombDimensionsIds } from './get.js'
import { getCombsDimensionsIds, getCombDimensionsIds } from './get.js'
import { isSameDimension, hasCrossDimensionsIds, findSameId } from './has.js'
import { setDimensionId, syncDimensionIds } from './set.js'

Expand All @@ -18,9 +18,10 @@ import { setDimensionId, syncDimensionIds } from './set.js'
// - We try to avoid creating new objects and arrays unless a mutation is
// actually needed, i.e. some id needs to be namespaced
// - We directly mutate the list of `dimensionsIds`
export const namespaceDimensionIds = function (rawResults) {
export const namespaceDimensionIds = function (rawResults, newCombinations) {
const dimensionsIds = getCombsDimensionsIds(newCombinations)
return rawResults.reduceRight(
namespaceRawResultIds.bind(undefined, []),
namespaceRawResultIds.bind(undefined, dimensionsIds),
rawResults,
)
}
Expand Down
6 changes: 3 additions & 3 deletions src/history/data/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const shouldRemoveFromHistory = async function (force) {

// Get a previous rawResult by delta
export const getFromHistory = async function (config) {
const rawResults = await listHistory(config)
const rawResults = await listHistory(config, [])
const { rawResult, previous } = await listResultsByDelta(rawResults, config)
return { rawResult, previous }
}
Expand All @@ -51,9 +51,9 @@ export const getFromHistory = async function (config) {
// This is performed at the beginning of all commands because this allows:
// - Failing fast if there is a problem with the history
// - Including previous|diff in rawResults preview
export const listHistory = async function ({ cwd, select }) {
export const listHistory = async function ({ cwd, select }, newCombinations) {
const rawResults = await listRawResults(cwd)
const rawResultsA = loadRawResults(rawResults, select)
const rawResultsA = loadRawResults(rawResults, select, newCombinations)
return rawResultsA
}

Expand Down
4 changes: 2 additions & 2 deletions src/history/normalize/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { decompressRawResult } from './compress.js'
import { migrateRawResults } from './migrate.js'

// Normalize rawResults on load
export const loadRawResults = function (rawResults, select) {
export const loadRawResults = function (rawResults, select, newCombinations) {
const rawResultsA = migrateRawResults(rawResults)
const rawResultsB = rawResultsA.map(decompressRawResult)
const rawResultsC = namespaceDimensionIds(rawResultsB)
const rawResultsC = namespaceDimensionIds(rawResultsB, newCombinations)
const rawResultsD = selectRawResults(rawResultsC, select)
const rawResultsE = sortResults(rawResultsD)
return rawResultsE
Expand Down
6 changes: 2 additions & 4 deletions src/run/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { createSystemInfo } from '../system/create/main.js'

// Create a new rawResult to measure
export const createResult = async function (config) {
const [combinations, previous] = await Promise.all([
listCombinations(config),
listHistory(config),
])
const combinations = await listCombinations(config)
const previous = await listHistory(config, combinations)
const { id, timestamp, system } = await createSystemInfo(combinations, config)
const rawResult = { id, timestamp, system, combinations }
return { rawResult, previous }
Expand Down

0 comments on commit 7958b8f

Please sign in to comment.