-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4206 - Data History: Fix and Simplify Data Sources differences (#4402)
* 4206 - Data History: Fix and Simplify Data Sources differences * 4206 - fix br DiffText
- Loading branch information
Showing
7 changed files
with
57 additions
and
54 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
30 changes: 30 additions & 0 deletions
30
.../Descriptions/NationalDataDescriptions/DataSources/hooks/_getDataSourceHistoryCompares.ts
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 @@ | ||
import { Arrays } from 'utils/arrays' | ||
|
||
import { DataSource } from 'meta/assessment' | ||
|
||
import { DataSourceHistoryCompare } from '../types' | ||
|
||
type Props = { | ||
dataSources: Array<DataSource> | ||
dataSourcesHistory: Array<DataSource> | ||
} | ||
type RecordDataSources = Record<string, DataSource> | ||
|
||
const _getRecordDataSources = (dataSources: Array<DataSource>): RecordDataSources => | ||
dataSources.reduce<RecordDataSources>((acc, dataSource) => ({ ...acc, [dataSource.uuid]: dataSource }), {}) | ||
|
||
export const getDataSourceHistoryCompares = (props: Props): Array<DataSourceHistoryCompare> => { | ||
const { dataSources, dataSourcesHistory } = props | ||
|
||
const recordDataSources = _getRecordDataSources(dataSources) | ||
const recordDataSourcesHistory = _getRecordDataSources(dataSourcesHistory) | ||
|
||
const uuids = Arrays.union(Object.keys(recordDataSources), Object.keys(recordDataSourcesHistory)) | ||
|
||
return uuids.map<DataSourceHistoryCompare>((uuid) => { | ||
const dataItem = recordDataSources[uuid] | ||
const historyItem = recordDataSourcesHistory[uuid] | ||
|
||
return { dataItem, historyItem } | ||
}) | ||
} |
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
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