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':
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;
}

14
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;

2
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
)

Loading…
Cancel
Save