forked from Sunbird-Obsrv/obsrv-web-console
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from Sanketika-Obsrv/release-branch
Release branch
- Loading branch information
Showing
22 changed files
with
629 additions
and
362 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { NextFunction, Request, Response } from "express"; | ||
import { fetchDataset, fetchDraftDataset } from "../services/dataset"; | ||
import _ from "lodash"; | ||
import { getDiff } from "json-difference"; | ||
|
||
export default { | ||
name: 'dataset:exists', | ||
handler: () => async (request: Request, response: Response, next: NextFunction) => { | ||
const { datasetId } = request.params; | ||
try { | ||
const liveDataset = await Promise.allSettled([fetchDataset({ datasetId })]) | ||
if(liveDataset[0].status == 'fulfilled') { | ||
return response.status(200).json(liveDataset[0].value) | ||
} | ||
|
||
const draftDataset = await Promise.allSettled([fetchDraftDataset({ datasetId })]) | ||
if(draftDataset[0].status == 'fulfilled') { | ||
return response.status(200).json(draftDataset[0].value) | ||
} | ||
|
||
if(draftDataset[0].status == 'rejected') { | ||
return response.status(_.get(draftDataset[0], ['reason', 'status'])).json(_.get(draftDataset[0], ['reason', 'response', 'data'])) | ||
} | ||
|
||
|
||
} catch (error) { | ||
next(error); | ||
} | ||
} | ||
}; |
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
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
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
Oops, something went wrong.