Browse Source

refactor(nocodb): rename date filter sub ops

pull/5185/head
Wing-Kam Wong 2 years ago
parent
commit
a43f6be47c
  1. 18
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts
  2. 14
      packages/nocodb/src/lib/models/Filter.ts
  3. 2
      packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0105003.ts

18
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts

@ -291,36 +291,36 @@ const parseConditionV2 = async (
case 'yesterday': case 'yesterday':
val = now.add(-1, 'day'); val = now.add(-1, 'day');
break; break;
case 'one_week_ago': case 'oneWeekAgo':
val = now.add(-7, 'day'); val = now.add(-7, 'day');
break; break;
case 'one_week_from_now': case 'oneWeekFromNow':
val = now.add(7, 'day'); val = now.add(7, 'day');
break; break;
case 'one_month_ago': case 'oneMonthAgo':
val = now.add(-1, 'month'); val = now.add(-1, 'month');
break; break;
case 'one_month_from_now': case 'oneMonthFromNow':
val = now.add(1, 'month'); val = now.add(1, 'month');
break; break;
case 'number_of_days_ago': case 'daysAgo':
if (!val) return; if (!val) return;
val = now.add(-val, 'day'); val = now.add(-val, 'day');
break; break;
case 'number_of_days_from_now': case 'daysFromNow':
if (!val) return; if (!val) return;
val = now.add(val, 'day'); val = now.add(val, 'day');
break; break;
case 'exact_date': case 'exactDate':
if (!val) return; if (!val) return;
break; break;
} }
if ( if (
filter.comparison_sub_op && filter.comparison_sub_op &&
filter.comparison_sub_op !== 'exact_date' filter.comparison_sub_op !== 'exactDate'
) { ) {
// val for exact_date is not a dayjs object // val for exactDate is not a dayjs object
val = val.format(dateFormat).toString(); val = val.format(dateFormat).toString();
val = column.uidt === UITypes.Date ? val.substring(0, 10) : val; val = column.uidt === UITypes.Date ? val.substring(0, 10) : val;
} }

14
packages/nocodb/src/lib/models/Filter.ts

@ -57,13 +57,13 @@ export default class Filter {
| 'today' | 'today'
| 'tomorrow' | 'tomorrow'
| 'yesterday' | 'yesterday'
| 'one_week_ago' | 'oneWeekAgo'
| 'one_week_from_now' | 'oneWeekFromNow'
| 'one_month_ago' | 'oneMonthAgo'
| 'one_month_from_now' | 'oneMonthFromNow'
| 'number_of_days_ago' | 'daysAgo'
| 'number_of_days_from_now' | 'daysFromNow'
| 'exact_date'; | 'exactDate';
value?: string; value?: string;

2
packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0105003.ts

@ -50,7 +50,7 @@ async function migrateEqAndNeqFilters(ncMeta: NcMetaIO) {
Filter.update( Filter.update(
filter.id, filter.id,
{ {
comparison_sub_op: 'exact_date', comparison_sub_op: 'exactDate',
}, },
ncMeta ncMeta
) )

Loading…
Cancel
Save