Skip to content

Commit

Permalink
fix validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Lai committed Sep 18, 2024
1 parent 615bb91 commit 15e4b60
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/pages/studyView/rfc80Tester.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ export const RFC80Test = observer(function() {
test.data,
test.label,
test.hash,
undefined,
undefined,
col.assertResponse
).then((report: any) => {
report.test = test;
Expand Down
56 changes: 40 additions & 16 deletions src/shared/api/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,36 @@ 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') };
});
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;
}
chXHR = $.ajax({
method: 'post',
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 chXHR
Expand Down Expand Up @@ -295,14 +317,16 @@ export function validate(
});
}
else {
return {
label,
url: url,
hash: hash,
status: true,
data: params,
chDuration: parseFloat(elapsedTime),
};
const result: any = compareCounts(
body,
assertResponse,
'ClinicalDataCounts'
);
result.url = url;
result.hash = hash;
result.data = params;
result.chDuration = parseFloat(elapsedTime);
return result;
}
})
.catch(() => {
Expand Down

0 comments on commit 15e4b60

Please sign in to comment.