Skip to content

Commit

Permalink
Start adding default ids logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jan 2, 2022
1 parent 45c7a62 commit 3b6a912
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/combination/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const addDefaultIds = function (history) {
return history
}
8 changes: 5 additions & 3 deletions src/history/normalize/load.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { addDefaultIds } from '../../combination/default.js'
import { keepResultCombinations } from '../../combination/result.js'
import { selectRawResult } from '../../select/main.js'
import { validateSelectMatches } from '../../select/validate.js'
Expand All @@ -15,12 +16,13 @@ export const loadRawResults = function (rawResults) {
// Normalize the history and target results after load, once the target result
// is known
export const normalizeRawResults = function (targetResult, history, config) {
const historyA = filterUnusedCombinations(history, targetResult)
const [targetResultA, ...historyB] = [targetResult, ...historyA].map(
const historyA = addDefaultIds(history, targetResult)
const historyB = filterUnusedCombinations(historyA, targetResult)
const [targetResultA, ...historyC] = [targetResult, ...historyB].map(
(rawResult) => normalizeRawResult(rawResult, config),
)
validateSelectMatches(targetResultA, config)
return { targetResult: targetResultA, history: historyB }
return { targetResult: targetResultA, history: historyC }
}

// We ignore the combinations from history results that do not exist in the
Expand Down

0 comments on commit 3b6a912

Please sign in to comment.