-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
33 additions
and
26 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
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,30 @@ | ||
// Rename the `id` of a dimensionId for a given combination's dimension | ||
export const setDimensionId = function ( | ||
combination, | ||
{ id, dimension: { propName } }, | ||
) { | ||
return { | ||
...combination, | ||
dimensions: { | ||
...combination.dimensions, | ||
[propName]: { ...combination.dimensions[propName], id }, | ||
}, | ||
} | ||
} | ||
|
||
// When updating `rawResult.combinations[*].dimensions[*].id`, we need to also | ||
// update some properties in `rawResult` which have the same value, | ||
// such as `rawResult.system.id`. | ||
export const syncDimensionIds = function (rawResult) { | ||
return renameSystemIds(rawResult) | ||
} | ||
|
||
// System ids are persisted in two places: `rawResult.system.id` and | ||
// `rawResult.combinations[*].dimensions.system`. | ||
// We need to update the former. | ||
const renameSystemIds = function (rawResult) { | ||
const { id } = rawResult.combinations[0].dimensions.system | ||
return rawResult.system.id === id | ||
? rawResult | ||
: { ...rawResult, system: { ...rawResult.system, id } } | ||
} |