-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom filter tests with new samples and assertResponse fields #4998
Changes from 6 commits
1aee750
615bb91
15e4b60
8b5d387
32a4faf
d355c0e
15780a2
a5a5932
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,7 +248,8 @@ export function validate( | |
label: string, | ||
hash: number, | ||
body?: any, | ||
elapsedTime?: any | ||
elapsedTime?: any, | ||
assertResponse?: any[] | ||
) { | ||
const clStart = performance.now(); | ||
let chDuration: number, legacyDuration: number; | ||
|
@@ -258,39 +259,75 @@ export function validate( | |
if (body) { | ||
chXHR = Promise.resolve({ body, elapsedTime }); | ||
} else { | ||
chXHR = $.ajax({ | ||
method: 'post', | ||
url: url, | ||
data: JSON.stringify(params), | ||
contentType: 'application/json', | ||
}).then((body, state, xhr) => { | ||
return { body, elapsedTime: xhr.getResponseHeader('elapsed-time') }; | ||
}); | ||
} | ||
|
||
return chXHR | ||
.then(({ body, elapsedTime }: any) => { | ||
let legacyUrl = url.replace(/column-store\//, ''); | ||
if (treatmentLegacyUrl[label]) { | ||
legacyUrl = treatmentLegacyUrl[label](legacyUrl); | ||
if (assertResponse && assertResponse[0] && assertResponse[0].attributeId) { | ||
let data: any = {}; | ||
data['attributes'] = [{ attributeId: assertResponse[0].attributeId }]; | ||
if (params.studyViewFilter) { | ||
const { | ||
attributes, | ||
...filteredStudyViewFilter | ||
} = params.studyViewFilter; | ||
data['studyViewFilter'] = filteredStudyViewFilter; | ||
} else { | ||
data['studyViewFilter'] = params; | ||
} | ||
const legacyXHR = $.ajax({ | ||
chXHR = $.ajax({ | ||
method: 'post', | ||
url: legacyUrl, | ||
url: '/api/column-store/clinical-data-counts/fetch?', | ||
data: JSON.stringify(data), | ||
contentType: 'application/json', | ||
}).then((body, state, xhr) => { | ||
return { body, elapsedTime: xhr.getResponseHeader('elapsed-time') }; | ||
}); | ||
} else { | ||
chXHR = $.ajax({ | ||
method: 'post', | ||
url: url, | ||
data: JSON.stringify(params), | ||
contentType: 'application/json', | ||
}).then((body, state, xhr) => { | ||
return { body, elapsedTime: xhr.getResponseHeader('elapsed-time') }; | ||
}); | ||
return legacyXHR.then(legacyResult => { | ||
const result: any = compareCounts(body, legacyResult, label); | ||
} | ||
} | ||
|
||
return chXHR | ||
alisman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.then(({ body, elapsedTime }: any) => { | ||
if (!assertResponse) { | ||
let legacyUrl = url.replace(/column-store\//, ''); | ||
if (treatmentLegacyUrl[label]) { | ||
legacyUrl = treatmentLegacyUrl[label](legacyUrl); | ||
} | ||
const legacyXHR = $.ajax({ | ||
method: 'post', | ||
url: legacyUrl, | ||
data: JSON.stringify(params), | ||
contentType: 'application/json', | ||
}); | ||
return legacyXHR.then(legacyResult => { | ||
const result: any = compareCounts(body, legacyResult, label); | ||
result.url = url; | ||
result.hash = hash; | ||
result.data = params; | ||
result.chDuration = parseFloat(elapsedTime); | ||
result.legacyDuration = parseFloat( | ||
legacyXHR.getResponseHeader('elapsed-time') || '' | ||
); | ||
return result; | ||
}); | ||
} | ||
else { | ||
const result: any = compareCounts( | ||
alisman marked this conversation as resolved.
Show resolved
Hide resolved
|
||
body, | ||
assertResponse, | ||
'ClinicalDataCounts' | ||
); | ||
result.url = url; | ||
result.hash = hash; | ||
result.data = params; | ||
result.chDuration = parseFloat(elapsedTime); | ||
result.legacyDuration = parseFloat( | ||
legacyXHR.getResponseHeader('elapsed-time') || '' | ||
); | ||
return result; | ||
}); | ||
} | ||
}) | ||
.catch(() => { | ||
const result: any = {}; | ||
|
@@ -324,13 +361,21 @@ export function reportValidationResult(result: any, prefix = '') { | |
}); | ||
|
||
result.status && | ||
console.log( | ||
`${prefix} ${result.label} (${ | ||
result.hash | ||
}) passed :) ch: ${result.chDuration.toFixed( | ||
0 | ||
)} legacy: ${result.legacyDuration.toFixed(0)}` | ||
); | ||
(!result.legacyDuration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. try to avoid these duplicating logic (console.log(...)) like this for only a "little" thing like whether it has legacyDuration. better to introduce a variable that gets always gets printed and can sometimes be blank (e.g. when there's no legacyDuration). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i do think it's a good idea to include the fact that there's an assertResponse in this console log here. |
||
? console.log( | ||
`${prefix} ${result.label} (${ | ||
result.hash | ||
}) assertResponse detected, passed :) ch: ${result.chDuration.toFixed( | ||
0 | ||
)}` | ||
) | ||
: console.log( | ||
`${prefix} ${result.label} (${ | ||
result.hash | ||
}) passed :) ch: ${result.chDuration.toFixed( | ||
0 | ||
)} legacy: ${result.legacyDuration.toFixed(0)}` | ||
)); | ||
|
||
if (!result.status) { | ||
_.forEach(result.clDataSorted, (cl: any, i: number) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure i understand the necessity of this code up here. the clickhouse fetch should be entirely independent of the assertResponse, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i used it to get the one attribute that is used in assertResponse. so the clinical data counts clickhouse fetch only fetches data for that attribute. then its an easy compare between that response and assertResponse.