-
Notifications
You must be signed in to change notification settings - Fork 4
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 #63 from KeithKelleher/master
Support data downloads for lists and details pages
- Loading branch information
Showing
35 changed files
with
2,385 additions
and
1,377 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,2 +1,4 @@ | ||
instance_class: F4 | ||
instance_class: F4_1G | ||
runtime: nodejs10 | ||
automatic_scaling: | ||
min_instances: 1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
const {DiseaseList} = require("../../models/disease/diseaseList"); | ||
const {tcrdConfig} = require('../../__utils/loadTCRDforTesting'); | ||
const TCRD = require('../../TCRD'); | ||
|
||
let tcrd = new TCRD(tcrdConfig); | ||
|
||
beforeAll(() => { | ||
return tcrd.tableInfo.loadPromise.then((res) => { | ||
return; | ||
}); | ||
}); | ||
|
||
describe('all the queries should be consistent with each other', function () { | ||
test('Disease batches are a thing too', () => { | ||
const diseaseList = ["asthma", "benign ependymoma"]; | ||
const fullList = new DiseaseList(tcrd); | ||
const batchList = new DiseaseList(tcrd, { | ||
batch: diseaseList | ||
}); | ||
|
||
const batchListQuery = batchList.getListQuery(); | ||
const batchCountQuery = batchList.getCountQuery(); | ||
const fullTdlFacet = fullList.facetsToFetch.find(f => f.name == 'Target Development Level').getFacetQuery(); | ||
const batchTdlFacet = batchList.facetsToFetch.find(f => f.name == 'Target Development Level').getFacetQuery(); | ||
|
||
return Promise.all([batchCountQuery, batchTdlFacet, fullTdlFacet, batchListQuery]).then(res => { | ||
const batchCount = res[0][0].count; | ||
expect(batchCount).toBe(diseaseList.length); | ||
const batchLength = res[3].length; | ||
expect(batchLength).toBe(diseaseList.length); | ||
|
||
const batchTdlCount = res[1].reduce((a, c) => a + c.value, 0); | ||
const fullTdlCount = res[2].reduce((a, c) => a + c.value, 0); | ||
expect(fullTdlCount).toBeGreaterThan(batchTdlCount); | ||
expect(batchTdlCount).toBeGreaterThan(0); | ||
}); | ||
}); | ||
|
||
|
||
test('All diseases query', () => { | ||
const fullList = new DiseaseList(tcrd); | ||
const filteredList = new DiseaseList(tcrd, {filter: {facets: [{facet: "Data Source", values: ["CTD"]}]}}); | ||
|
||
const fullCountQuery = fullList.getCountQuery(); | ||
const fullListQuery = fullList.getListQuery(); | ||
const fullTypeFacet = fullList.facetsToFetch.find(facet => facet.name === 'Target Development Level'); | ||
const fullTypeFacetQuery = fullTypeFacet.getFacetQuery(); | ||
|
||
const filteredCountQuery = filteredList.getCountQuery(); | ||
const filteredListQuery = filteredList.getListQuery(); | ||
const filteredTypeFacet = filteredList.facetsToFetch.find(facet => facet.name === 'Target Development Level'); | ||
const filteredTypeFacetQuery = filteredTypeFacet.getFacetQuery(); | ||
const filteredTypeConstraintQuery = filteredList.filteringFacets[0].getFacetConstraintQuery(); | ||
|
||
return Promise.all( | ||
[fullCountQuery, fullListQuery, fullTypeFacetQuery, | ||
filteredCountQuery, filteredListQuery, filteredTypeFacetQuery, | ||
filteredTypeConstraintQuery]) | ||
.then(res => { | ||
const fullCount = res[0][0].count; | ||
const fullListLength = res[1].length; | ||
expect(fullCount).toBe(fullListLength); | ||
const fullTypeCount = res[2].reduce((a, c) => a + c.value, 0); | ||
expect(fullTypeCount).toBeGreaterThanOrEqual(fullListLength); | ||
|
||
const filteredCount = res[3][0].count; | ||
const filteredListLength = res[4].length; | ||
expect(filteredCount).toBe(filteredListLength); | ||
const filteredTypeCount = res[5].reduce((a, c) => a + c.value, 0); | ||
expect(filteredTypeCount).toBeGreaterThanOrEqual(filteredListLength); | ||
|
||
const facetConstraintList = res[6].length; | ||
|
||
expect(facetConstraintList).toBe(filteredListLength); | ||
expect(fullCount).toBeGreaterThan(filteredCount); | ||
expect(fullTypeCount).toBeGreaterThan(filteredTypeCount); | ||
|
||
expect(fullCount).toBeGreaterThan(0); | ||
expect(filteredCount).toBeGreaterThan(0); | ||
|
||
console.log(fullCount); | ||
console.log(filteredCount); | ||
}); | ||
}); | ||
|
||
|
||
test('term search query', () => { | ||
const fullList = new DiseaseList(tcrd, {top: 20000, filter: {term: "cancer"}}); | ||
const filteredList = new DiseaseList(tcrd, { | ||
top: 20000, | ||
filter: {term: "cancer", facets: [{facet: "Data Source", values: ["CTD"]}]} | ||
}); | ||
|
||
const fullCountQuery = fullList.getCountQuery(); | ||
const fullListQuery = fullList.getListQuery(); | ||
const fullTypeFacet = fullList.facetsToFetch.find(facet => facet.name === 'Target Development Level'); | ||
const fullTypeFacetQuery = fullTypeFacet.getFacetQuery(); | ||
|
||
const filteredCountQuery = filteredList.getCountQuery(); | ||
const filteredListQuery = filteredList.getListQuery(); | ||
const filteredTypeFacet = filteredList.facetsToFetch.find(facet => facet.name === 'Target Development Level'); | ||
const filteredTypeFacetQuery = filteredTypeFacet.getFacetQuery(); | ||
const filteredTypeConstraintQuery = filteredList.filteringFacets[0].getFacetConstraintQuery(); | ||
|
||
return Promise.all( | ||
[fullCountQuery, fullListQuery, fullTypeFacetQuery, | ||
filteredCountQuery, filteredListQuery, filteredTypeFacetQuery, | ||
filteredTypeConstraintQuery]) | ||
.then(res => { | ||
const fullCount = res[0][0].count; | ||
const fullListLength = res[1].length; | ||
expect(fullCount).toBe(fullListLength); | ||
const fullTypeCount = res[2].reduce((a, c) => a + c.value, 0); | ||
expect(fullTypeCount).toBeGreaterThanOrEqual(fullListLength); // only true for TDL because of multiple targets associated with these diseases | ||
// ideally they'd be equal and add up exactly like in the target / ligand test facets | ||
const filteredCount = res[3][0].count; | ||
const filteredListLength = res[4].length; | ||
expect(filteredCount).toBe(filteredListLength); | ||
const filteredTypeCount = res[5].reduce((a, c) => a + c.value, 0); | ||
expect(filteredTypeCount).toBeGreaterThanOrEqual(filteredListLength); | ||
|
||
const facetConstraintList = res[6].length; | ||
|
||
// expect(facetConstraintList).toBe(filteredListLength); | ||
expect(fullCount).toBeGreaterThan(filteredCount); | ||
expect(fullTypeCount).toBeGreaterThan(filteredTypeCount); | ||
|
||
expect(fullCount).toBeGreaterThan(0); | ||
expect(filteredCount).toBeGreaterThan(0); | ||
|
||
console.log(fullCount); | ||
console.log(filteredCount); | ||
}); | ||
}); | ||
|
||
test('associated target query', () => { | ||
const fullList = new DiseaseList(tcrd, {top: 20000, filter: {associatedTarget: "DRD2"}}); | ||
const filteredList = new DiseaseList(tcrd, { | ||
top: 20000, | ||
filter: {associatedTarget: "DRD2", facets: [{facet: "Data Source", values: ["CTD"]}]} | ||
}); | ||
|
||
const fullCountQuery = fullList.getCountQuery(); | ||
const fullListQuery = fullList.getListQuery(); | ||
const fullTypeFacet = fullList.facetsToFetch.find(facet => facet.name === 'Drug'); | ||
const fullTypeFacetQuery = fullTypeFacet.getFacetQuery(); | ||
|
||
const filteredCountQuery = filteredList.getCountQuery(); | ||
const filteredListQuery = filteredList.getListQuery(); | ||
const filteredTypeFacet = filteredList.facetsToFetch.find(facet => facet.name === 'Drug'); | ||
const filteredTypeFacetQuery = filteredTypeFacet.getFacetQuery(); | ||
const filteredTypeConstraintQuery = filteredList.filteringFacets[0].getFacetConstraintQuery(); | ||
|
||
return Promise.all( | ||
[fullCountQuery, fullListQuery, fullTypeFacetQuery, | ||
filteredCountQuery, filteredListQuery, filteredTypeFacetQuery, | ||
filteredTypeConstraintQuery]) | ||
.then(res => { | ||
const fullCount = res[0][0].count; | ||
const fullListLength = res[1].length; | ||
expect(fullCount).toBe(fullListLength); | ||
const fullTypeCount = res[2].reduce((a, c) => a + c.value, 0); | ||
// expect(fullTypeCount).toBeGreaterThanOrEqual(fullListLength); // not true for drugs because they are sparse | ||
|
||
const filteredCount = res[3][0].count; | ||
const filteredListLength = res[4].length; | ||
expect(filteredCount).toBe(filteredListLength); | ||
const filteredTypeCount = res[5].reduce((a, c) => a + c.value, 0); | ||
// expect(filteredTypeCount).toBeGreaterThanOrEqual(filteredListLength); | ||
|
||
const facetConstraintList = res[6].length; | ||
|
||
// expect(facetConstraintList).toBe(filteredListLength); | ||
expect(fullCount).toBeGreaterThan(filteredCount); | ||
expect(fullTypeCount).toBeGreaterThan(filteredTypeCount); | ||
|
||
expect(fullCount).toBeGreaterThan(0); | ||
expect(filteredCount).toBeGreaterThan(0); | ||
|
||
console.log(fullCount); | ||
console.log(filteredCount); | ||
}); | ||
}); | ||
|
||
}); |
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.