2018-08-10 16:49:38 -07:00
|
|
|
import { datasetUrlByUrn } from 'wherehows-web/utils/api/datasets/shared';
|
|
|
|
import { getJSON } from 'wherehows-web/utils/api/fetcher';
|
|
|
|
import { IHealthScoreResponse, IDatasetHealth } from 'wherehows-web/typings/api/datasets/health';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the url for dataset metadata health by urn
|
|
|
|
* @param urn
|
|
|
|
* @return {string}
|
|
|
|
*/
|
|
|
|
const datasetHealthUrlByUrn = (urn: string): string => `${datasetUrlByUrn(urn)}/health`;
|
|
|
|
|
|
|
|
export const readDatasetHealthByUrn = async (urn: string): Promise<IDatasetHealth> => {
|
2018-08-13 11:44:50 -07:00
|
|
|
const { health } = await getJSON<IHealthScoreResponse>({ url: datasetHealthUrlByUrn(urn) });
|
2018-08-10 16:49:38 -07:00
|
|
|
|
2018-08-13 11:44:50 -07:00
|
|
|
return health || { score: 0, validations: [] };
|
2018-08-10 16:49:38 -07:00
|
|
|
};
|