forked from uc-cdis/commons-frontend-app
-
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.
add sample data to nextJS API routes
- Loading branch information
1 parent
61689e9
commit 098a394
Showing
10 changed files
with
570 additions
and
257 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 was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
...overlap/by-source-id/[sourceId]/by-cohort-definition-ids/[cohortAId]/[cohortBId]/index.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,34 @@ | ||
import { NextApiRequest, NextApiResponse } from 'next'; | ||
import { CohortOverlap } from '@/lib/AnalysisApps/GWAS/Utils/cohortApi'; | ||
|
||
interface PathParameters { | ||
sourceId: string; | ||
cohortAId: string; | ||
cohortBId: string; | ||
} | ||
const handler = async (req: NextApiRequest, res: NextApiResponse) => { | ||
// Get the sourceId from the slug in the path | ||
const { query } = req; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { sourceId, cohortAId, cohortBId } = query as unknown as PathParameters; // messy but this is for development | ||
|
||
const data: Record<string, Record<string, CohortOverlap>> = { | ||
'1537': { | ||
'446': { cohort_overlap: { case_control_overlap: 236021 } }, | ||
'2356': { cohort_overlap: { case_control_overlap: 236021 } }, | ||
}, | ||
'446': { | ||
'2356': { cohort_overlap: { case_control_overlap: 648242 } }, | ||
}, | ||
}; | ||
|
||
if (data[cohortAId] && data[cohortAId][cohortBId]) { | ||
return res.status(200).json(data[cohortAId][cohortBId]); | ||
} | ||
if (data[cohortBId] && data[cohortBId][cohortAId]) { | ||
return res.status(200).json(data[cohortBId][cohortAId]); | ||
} | ||
return res.status(200).json({ cohort_overlap: { case_control_overlap: 648242 }}); | ||
|
||
}; | ||
export default handler; |
33 changes: 33 additions & 0 deletions
33
src/pages/api/cohortdefinition-stats/by-source-id/[sourceId]/by-team-project/index.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,33 @@ | ||
import { NextApiRequest, NextApiResponse } from 'next'; | ||
|
||
const handler = async (req: NextApiRequest, res: NextApiResponse) => { | ||
|
||
// Get the sourceId from the slug in the path | ||
// const { query } = req; | ||
// const { sourceId } = query; | ||
return res.status(200).json({ | ||
cohort_definitions_and_stats: [ | ||
{ | ||
cohort_definition_id: 573, | ||
cohort_name: 'team2 - test new cohort - catch all', | ||
size: 70240, | ||
}, | ||
{ | ||
cohort_definition_id: 559, | ||
cohort_name: 'test new cohort - catch all', | ||
size: 70240, | ||
}, | ||
{ | ||
cohort_definition_id: 574, | ||
cohort_name: 'team2 - test new cohort - medium + large', | ||
size: 23800, | ||
}, | ||
{ | ||
cohort_definition_id: 575, | ||
cohort_name: 'team2 - test new cohort - small', | ||
size: 80, | ||
}, | ||
], | ||
}); | ||
}; | ||
export default handler; |
Oops, something went wrong.