Browse Source

refactor(nocodb): move duplicate logic out

pull/5185/head
Wing-Kam Wong 2 years ago
parent
commit
993660638f
  1. 41
      packages/nocodb/src/lib/meta/api/sync/helpers/job.ts

41
packages/nocodb/src/lib/meta/api/sync/helpers/job.ts

@ -1998,17 +1998,12 @@ export default async (
const ncFilters = []; const ncFilters = [];
if (datatype === UITypes.Date || datatype === UITypes.DateTime) { if (datatype === UITypes.Date || datatype === UITypes.DateTime) {
let comparison_op = null;
let comparison_sub_op = null;
let value = null;
if (['isEmpty', 'isNotEmpty'].includes(filter.operator)) { if (['isEmpty', 'isNotEmpty'].includes(filter.operator)) {
const fx = { comparison_op = filter.operator === 'isEmpty' ? 'blank' : 'notblank';
fk_column_id: columnId,
logical_op: f.conjunction,
comparison_op: filter.operator === 'isEmpty' ? 'blank' : 'notblank',
value: null,
};
ncFilters.push(fx);
} else if (filter.operator === 'isWithin') { } else if (filter.operator === 'isWithin') {
let comparison_sub_op = null;
let value = null;
switch (filter.value.mode) { switch (filter.value.mode) {
case 'pastWeek': case 'pastWeek':
comparison_sub_op = 'oneWeekAgo'; comparison_sub_op = 'oneWeekAgo';
@ -2039,30 +2034,24 @@ export default async (
value = filter.value.numberOfDays; value = filter.value.numberOfDays;
break; break;
} }
const fx = { comparison_op = filter.operator;
fk_column_id: columnId,
logical_op: f.conjunction,
comparison_op: filter.operator,
comparison_sub_op,
value,
};
ncFilters.push(fx);
} else { } else {
let value = null;
if ('numberOfDays' in filter.value) { if ('numberOfDays' in filter.value) {
value = filter.value['numberOfDays']; value = filter.value['numberOfDays'];
} else if ('exactDate' in filter.value) { } else if ('exactDate' in filter.value) {
value = filter.value['exactDate']; value = filter.value['exactDate'];
} }
const fx = { comparison_op = filterMap[filter.operator];
fk_column_id: columnId, comparison_sub_op = filter.value.mode;
logical_op: f.conjunction,
comparison_op: filterMap[filter.operator],
comparison_sub_op: filter.value.mode,
value,
};
ncFilters.push(fx);
} }
const fx = {
fk_column_id: columnId,
logical_op: f.conjunction,
comparison_op,
comparison_sub_op,
value,
};
ncFilters.push(fx);
} }
// single-select & multi-select // single-select & multi-select

Loading…
Cancel
Save