Browse Source

refactor(nocodb): move duplicate logic out

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

31
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) {
if (['isEmpty', 'isNotEmpty'].includes(filter.operator)) { let comparison_op = null;
const fx = {
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') {
let comparison_sub_op = null; let comparison_sub_op = null;
let value = null; let value = null;
if (['isEmpty', 'isNotEmpty'].includes(filter.operator)) {
comparison_op = filter.operator === 'isEmpty' ? 'blank' : 'notblank';
} else if (filter.operator === 'isWithin') {
switch (filter.value.mode) { switch (filter.value.mode) {
case 'pastWeek': case 'pastWeek':
comparison_sub_op = 'oneWeekAgo'; comparison_sub_op = 'oneWeekAgo';
@ -2039,31 +2034,25 @@ 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'];
} }
comparison_op = filterMap[filter.operator];
comparison_sub_op = filter.value.mode;
}
const fx = { const fx = {
fk_column_id: columnId, fk_column_id: columnId,
logical_op: f.conjunction, logical_op: f.conjunction,
comparison_op: filterMap[filter.operator], comparison_op,
comparison_sub_op: filter.value.mode, comparison_sub_op,
value, value,
}; };
ncFilters.push(fx); ncFilters.push(fx);
} }
}
// single-select & multi-select // single-select & multi-select
else if ( else if (

Loading…
Cancel
Save