-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(odd-platform-ui): add initial data to improve chart loading (#1590)
- Loading branch information
1 parent
4fa7c26
commit a4e1b7c
Showing
1 changed file
with
70 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,82 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import type { DataQualityRunsApiGetDataQualityTestsRunsRequest } from 'generated-sources/apis/DataQualityRunsApi'; | ||
import { dataQualityRunsApi } from 'lib/api'; | ||
import type { DataQualityResults } from 'generated-sources/models/DataQualityResults'; | ||
import type { DataQualityRunStatusCount } from 'generated-sources/models/DataQualityRunStatusCount'; | ||
|
||
const emptyTestResults: Array<DataQualityRunStatusCount> = [ | ||
{ | ||
status: 'SUCCESS', | ||
count: 0, | ||
}, | ||
{ | ||
status: 'FAILED', | ||
count: 0, | ||
}, | ||
{ | ||
status: 'SKIPPED', | ||
count: 0, | ||
}, | ||
{ | ||
status: 'BROKEN', | ||
count: 0, | ||
}, | ||
{ | ||
status: 'ABORTED', | ||
count: 0, | ||
}, | ||
{ | ||
status: 'UNKNOWN', | ||
count: 0, | ||
}, | ||
]; | ||
|
||
const initialData: DataQualityResults = { | ||
testResults: [ | ||
{ | ||
category: 'Assertion Tests', | ||
results: [...emptyTestResults], | ||
}, | ||
{ | ||
category: 'Freshness Anomalies', | ||
results: [...emptyTestResults], | ||
}, | ||
{ | ||
category: 'Schema Changes', | ||
results: [...emptyTestResults], | ||
}, | ||
{ | ||
category: 'Volume Anomalies', | ||
results: [...emptyTestResults], | ||
}, | ||
{ | ||
category: 'Column Values Anomalies', | ||
results: [...emptyTestResults], | ||
}, | ||
{ | ||
category: 'Unknown category', | ||
results: [...emptyTestResults], | ||
}, | ||
], | ||
tablesDashboard: { | ||
tablesHealth: { | ||
healthyTables: 0, | ||
errorTables: 0, | ||
warningTables: 0, | ||
}, | ||
monitoredTables: { | ||
monitoredTables: 0, | ||
notMonitoredTables: 0, | ||
}, | ||
}, | ||
}; | ||
|
||
export function useGetDataQualityDashboard( | ||
params: DataQualityRunsApiGetDataQualityTestsRunsRequest | ||
) { | ||
return useQuery({ | ||
queryKey: ['dataQualityDashboard', params], | ||
queryFn: async () => dataQualityRunsApi.getDataQualityTestsRuns(params), | ||
initialData, | ||
}); | ||
} |