rez_core 2.0.67 → 2.0.68

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": "2.0.67",
3
+ "version": "2.0.68",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -268,6 +268,8 @@ export class FilterService {
268
268
  return this.buildSelectCondition(attr, op, val, key);
269
269
  case 'multiselect':
270
270
  return this.buildMultiSelectCondition(attr, op, val, key);
271
+ case 'year':
272
+ return this.buildYearCondition(attr, op, val, key);
271
273
  default:
272
274
  return null;
273
275
  }
@@ -338,7 +340,6 @@ export class FilterService {
338
340
  }
339
341
  }
340
342
 
341
- // this can be inproved
342
343
  private buildSelectCondition(
343
344
  attr: string,
344
345
  op: string,
@@ -348,16 +349,12 @@ export class FilterService {
348
349
  switch (op) {
349
350
  case 'equal':
350
351
  return { query: `e.${attr} = :${key}`, params: { [key]: val } };
351
-
352
352
  case 'not_equal':
353
353
  return { query: `e.${attr} != :${key}`, params: { [key]: val } };
354
-
355
354
  case 'empty':
356
355
  return { query: `e.${attr} IS NULL`, params: {} };
357
-
358
356
  case 'not_empty':
359
357
  return { query: `e.${attr} IS NOT NULL`, params: {} };
360
-
361
358
  default:
362
359
  throw new BadRequestException(`Unsupported operator for select: ${op}`);
363
360
  }
@@ -385,23 +382,46 @@ export class FilterService {
385
382
  query: `e.${attr} IN (:${key})`,
386
383
  params: { [key]: val },
387
384
  };
388
-
389
385
  case 'not_equal':
390
386
  return {
391
387
  query: `e.${attr} NOT IN (:${key})`,
392
388
  params: { [key]: val },
393
389
  };
394
-
395
390
  case 'empty':
396
391
  return { query: `e.${attr} IS NULL`, params: {} };
397
-
398
392
  case 'not_empty':
399
393
  return { query: `e.${attr} IS NOT NULL`, params: {} };
400
-
401
394
  default:
402
395
  throw new BadRequestException(
403
396
  `Unsupported operator for multiselect: ${op}`,
404
397
  );
405
398
  }
406
399
  }
400
+
401
+ private buildYearCondition(attr: string, op: string, val: any, key: string) {
402
+ switch (op) {
403
+ case 'equal':
404
+ return {
405
+ query: `e.${attr} = :${key}`,
406
+ params: { [key]: parseInt(val, 10) },
407
+ };
408
+ case 'not_equal':
409
+ return {
410
+ query: `e.${attr} != :${key}`,
411
+ params: { [key]: parseInt(val, 10) },
412
+ };
413
+ case 'greater_than':
414
+ return {
415
+ query: `e.${attr} > :${key}`,
416
+ params: { [key]: parseInt(val, 10) },
417
+ };
418
+ case 'less_than':
419
+ return {
420
+ query: `e.${attr} < :${key}`,
421
+ params: { [key]: parseInt(val, 10) },
422
+ };
423
+ default:
424
+ throw new BadRequestException(`Unsupported operator for year: ${op}`);
425
+ }
426
+ }
407
427
  }