rez_core 5.0.79 → 5.0.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "5.0.79",
3
+ "version": "5.0.80",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -10,7 +10,6 @@ import { EntityRelationService } from 'src/module/meta/service/entity-relation.s
10
10
  import { ResolverService } from 'src/module/meta/service/resolver.service';
11
11
  import { LoggingService } from 'src/utils/service/loggingUtil.service';
12
12
  import { ConfigService } from '@nestjs/config';
13
- import dayjs from 'dayjs';
14
13
 
15
14
  @Injectable()
16
15
  export class FilterService {
@@ -1101,75 +1100,34 @@ export class FilterService {
1101
1100
  }
1102
1101
 
1103
1102
  case 'is_after_business_days': {
1104
- const days = Number(val);
1105
-
1106
- if (isNaN(days)) {
1103
+ if (isNaN(numVal)) {
1107
1104
  throw new BadRequestException(
1108
1105
  'Value must be a number for is_after_business_days',
1109
1106
  );
1110
1107
  }
1111
1108
 
1112
- let targetDate = dayjs().startOf('day'); // MUST be let
1113
- let count = 0;
1109
+ const businessAfter = (() => {
1110
+ let d = new Date();
1111
+ let count = 0;
1114
1112
 
1115
- while (count < days) {
1116
- targetDate = targetDate.add(1, 'day'); // ✔ FIX: assign back
1113
+ while (count < numVal) {
1114
+ d.setDate(d.getDate() + 1);
1115
+ const day = d.getDay(); // 0=Sun, 6=Sat
1116
+ if (day !== 0 && day !== 6) count++;
1117
+ }
1117
1118
 
1118
- const day = targetDate.day(); // 0 = Sunday, 6 = Saturday
1119
+ // DB shift -1 day
1120
+ d.setDate(d.getDate() - 1);
1119
1121
 
1120
- if (day !== 0 && day !== 6) {
1121
- count++;
1122
- }
1123
- }
1122
+ return d.toISOString().split('T')[0];
1123
+ })();
1124
1124
 
1125
1125
  return {
1126
- query: `DATE(e.${attr}) > :${key}`,
1127
- params: { [key]: targetDate.format('YYYY-MM-DD') },
1126
+ query: `${dateColumn} > :${key}`,
1127
+ params: { [key]: businessAfter },
1128
1128
  };
1129
1129
  }
1130
1130
 
1131
- // case 'is_before_business_days': {
1132
- // if (isNaN(numVal)) {
1133
- // throw new BadRequestException('Value must be a number');
1134
- // }
1135
-
1136
- // const targetDate = subtractBusinessDays(numVal);
1137
-
1138
- // return {
1139
- // query: `${dateColumn} <= :${key}`,
1140
- // params: { [key]: targetDate },
1141
- // };
1142
- // }
1143
-
1144
- // case 'is_after_business_days': {
1145
- // if (isNaN(numVal)) {
1146
- // throw new BadRequestException(
1147
- // 'Value must be a number for is_after_business_days',
1148
- // );
1149
- // }
1150
-
1151
- // const businessAfter = (() => {
1152
- // let d = new Date();
1153
- // let count = 0;
1154
-
1155
- // while (count < numVal) {
1156
- // d.setDate(d.getDate() + 1);
1157
- // const day = d.getDay(); // 0=Sun, 6=Sat
1158
- // if (day !== 0 && day !== 6) count++;
1159
- // }
1160
-
1161
- // // DB shift -1 day
1162
- // d.setDate(d.getDate() - 1);
1163
-
1164
- // return d.toISOString().split('T')[0];
1165
- // })();
1166
-
1167
- // return {
1168
- // query: `${dateColumn} > :${key}`,
1169
- // params: { [key]: businessAfter },
1170
- // };
1171
- // }
1172
-
1173
1131
  // ============================================
1174
1132
  // IN LAST DAY (range: today to N days before)
1175
1133
  // ============================================