From a43f6be47cc11062c633b1d043d6c309db652b64 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 24 Feb 2023 16:50:57 +0800 Subject: [PATCH] refactor(nocodb): rename date filter sub ops --- .../db/sql-data-mapper/lib/sql/conditionV2.ts | 18 +++++++++--------- packages/nocodb/src/lib/models/Filter.ts | 14 +++++++------- .../ncFilterUpgrader_0105003.ts | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts index dd5bff9424..cc1d5f97ea 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts @@ -291,36 +291,36 @@ const parseConditionV2 = async ( case 'yesterday': val = now.add(-1, 'day'); break; - case 'one_week_ago': + case 'oneWeekAgo': val = now.add(-7, 'day'); break; - case 'one_week_from_now': + case 'oneWeekFromNow': val = now.add(7, 'day'); break; - case 'one_month_ago': + case 'oneMonthAgo': val = now.add(-1, 'month'); break; - case 'one_month_from_now': + case 'oneMonthFromNow': val = now.add(1, 'month'); break; - case 'number_of_days_ago': + case 'daysAgo': if (!val) return; val = now.add(-val, 'day'); break; - case 'number_of_days_from_now': + case 'daysFromNow': if (!val) return; val = now.add(val, 'day'); break; - case 'exact_date': + case 'exactDate': if (!val) return; break; } if ( 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 = column.uidt === UITypes.Date ? val.substring(0, 10) : val; } diff --git a/packages/nocodb/src/lib/models/Filter.ts b/packages/nocodb/src/lib/models/Filter.ts index 1267e2a5e9..f083d9f3e7 100644 --- a/packages/nocodb/src/lib/models/Filter.ts +++ b/packages/nocodb/src/lib/models/Filter.ts @@ -57,13 +57,13 @@ export default class Filter { | 'today' | 'tomorrow' | 'yesterday' - | 'one_week_ago' - | 'one_week_from_now' - | 'one_month_ago' - | 'one_month_from_now' - | 'number_of_days_ago' - | 'number_of_days_from_now' - | 'exact_date'; + | 'oneWeekAgo' + | 'oneWeekFromNow' + | 'oneMonthAgo' + | 'oneMonthFromNow' + | 'daysAgo' + | 'daysFromNow' + | 'exactDate'; value?: string; diff --git a/packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0105003.ts b/packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0105003.ts index 8ddf5f6b48..61caba1fc1 100644 --- a/packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0105003.ts +++ b/packages/nocodb/src/lib/version-upgrader/ncFilterUpgrader_0105003.ts @@ -50,7 +50,7 @@ async function migrateEqAndNeqFilters(ncMeta: NcMetaIO) { Filter.update( filter.id, { - comparison_sub_op: 'exact_date', + comparison_sub_op: 'exactDate', }, ncMeta )