Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions frontend/lib/js/api/apiHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
// (to exclude others that are relevant to the frontend only)
// Some keys are added (e.g. the query type attribute)

import {
DAYS_BEFORE,
DAYS_OR_NO_EVENT_BEFORE,
} from '../common/constants/timebasedQueryOperatorTypes';
// TODO: Use, once feature is complete
// import {
// DAYS_BEFORE,
// DAYS_OR_NO_EVENT_BEFORE,
// } from '../common/constants/timebasedQueryOperatorTypes';

import {
isEmpty
Expand Down Expand Up @@ -114,28 +115,31 @@ const createQueryConcepts = (query) => {
})
}

const getDayRange = (condition) => {
if (condition.operator === DAYS_BEFORE)
return [
{ minDays: condition.minDays },
{ maxDays: condition.maxDays },
];
// TODO: Use, once feature is complete
// const getDayRange = (condition) => {
// if (condition.operator === DAYS_BEFORE)
// return [
// { minDays: condition.minDays },
// { maxDays: condition.maxDays },
// ];

if (condition.operator === DAYS_OR_NO_EVENT_BEFORE)
return [
{ minDays: condition.minDaysOrNoEvent },
{ maxDays: condition.maxDaysOrNoEvent },
];
// if (condition.operator === DAYS_OR_NO_EVENT_BEFORE)
// return [
// { minDays: condition.minDaysOrNoEvent },
// { maxDays: condition.maxDaysOrNoEvent },
// ];

return [{}, {}];
};
// return [{}, {}];
// };

const transformTimebasedQueryToApi = (query) => ({
type: "CONCEPT_QUERY",
root: {
type: "AND",
children: query.conditions.map(condition => {
const [ minDays, maxDays ] = getDayRange(condition);
// TODO: Use, once feature is complete
// const [ minDays, maxDays ] = getDayRange(condition);

return {
type: condition.operator,
sampler: "EARLIEST",
Expand Down