@outliant/sunrise-utils 1.0.9 → 1.0.11
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/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,25 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [1.0.11](https://github.com/outliant/sunrise-utils/compare/1.0.10...1.0.11)
|
|
8
|
+
|
|
9
|
+
- (task/additional date filters #860q65z6h [`#4`](https://github.com/outliant/sunrise-utils/pull/4)
|
|
10
|
+
- chore: add last n days [`bb2f94a`](https://github.com/outliant/sunrise-utils/commit/bb2f94aade4ed11845ca29cf7f9b970cac51ae42)
|
|
11
|
+
- chore: add new filters for task [`3fa42e5`](https://github.com/outliant/sunrise-utils/commit/3fa42e52bc6076dfd35272b91558d9696729cfbf)
|
|
12
|
+
- chore: add new filters [`6f10233`](https://github.com/outliant/sunrise-utils/commit/6f1023325c1166f046dfac50695ceb68873fbb17)
|
|
13
|
+
|
|
14
|
+
#### [1.0.10](https://github.com/outliant/sunrise-utils/compare/1.0.9...1.0.10)
|
|
15
|
+
|
|
16
|
+
> 30 March 2023
|
|
17
|
+
|
|
18
|
+
- chore: added created and updated on project list columns #860qbm263 [`8f664f1`](https://github.com/outliant/sunrise-utils/commit/8f664f117644d97e5338f11c0f4e1a4396375b07)
|
|
19
|
+
- chore(release): 1.0.10 [`08ef0d6`](https://github.com/outliant/sunrise-utils/commit/08ef0d6b47ff16e853249d21d5d0b0a962caf44b)
|
|
20
|
+
|
|
7
21
|
#### [1.0.9](https://github.com/outliant/sunrise-utils/compare/1.0.8...1.0.9)
|
|
8
22
|
|
|
23
|
+
> 30 March 2023
|
|
24
|
+
|
|
25
|
+
- chore(release): 1.0.9 [`b866dd4`](https://github.com/outliant/sunrise-utils/commit/b866dd4b473c10534c8fe10d6a388a905fb8f0c1)
|
|
9
26
|
- chore: support taskfield group #860pn480e [`9bded12`](https://github.com/outliant/sunrise-utils/commit/9bded1255c994ea01823b1b689aa38d80da76c8a)
|
|
10
27
|
|
|
11
28
|
#### [1.0.8](https://github.com/outliant/sunrise-utils/compare/1.0.7...1.0.8)
|
|
@@ -59,6 +59,18 @@ module.exports.defaultCustomColumns = [
|
|
|
59
59
|
value: 'lastPulseCommentDate',
|
|
60
60
|
type: 'lastPulseCommentDate',
|
|
61
61
|
field_type: 'date'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'Created',
|
|
65
|
+
value: 'created_at',
|
|
66
|
+
type: 'created_at',
|
|
67
|
+
field_type: 'date'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'Updated',
|
|
71
|
+
value: 'updated_at',
|
|
72
|
+
type: 'updated_at',
|
|
73
|
+
field_type: 'date'
|
|
62
74
|
}
|
|
63
75
|
];
|
|
64
76
|
|
|
@@ -55,6 +55,10 @@ module.exports = (filter) => {
|
|
|
55
55
|
return module.exports.isAfterIncludeParam(filter);
|
|
56
56
|
case 'between':
|
|
57
57
|
return module.exports.isBetween(filter);
|
|
58
|
+
case 'next_n_days':
|
|
59
|
+
return module.exports.nextNDays(filter);
|
|
60
|
+
case 'last_n_days':
|
|
61
|
+
return module.exports.lastNDays(filter);
|
|
58
62
|
default:
|
|
59
63
|
return null;
|
|
60
64
|
}
|
|
@@ -495,6 +499,111 @@ module.exports.isAfter = (filter) => {
|
|
|
495
499
|
return null;
|
|
496
500
|
};
|
|
497
501
|
|
|
502
|
+
module.exports.nextNDays = (filter) => {
|
|
503
|
+
if (!!filter.field_id) {
|
|
504
|
+
if (isNaN(filter.value)) {
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
const today = moment()
|
|
509
|
+
.startOf('day');
|
|
510
|
+
|
|
511
|
+
const nextNDays = moment()
|
|
512
|
+
.add(filter.value, 'd')
|
|
513
|
+
.endOf('day');
|
|
514
|
+
|
|
515
|
+
const res = {
|
|
516
|
+
bool: {
|
|
517
|
+
must: [
|
|
518
|
+
{
|
|
519
|
+
nested: {
|
|
520
|
+
path: 'fields',
|
|
521
|
+
query: {
|
|
522
|
+
bool: {
|
|
523
|
+
must: [
|
|
524
|
+
{
|
|
525
|
+
term: {
|
|
526
|
+
'fields.id': {
|
|
527
|
+
value: filter.field_id
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
range: {
|
|
533
|
+
'fields.number': {
|
|
534
|
+
gt: today.valueOf(),
|
|
535
|
+
lt: nextNDays.valueOf()
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
]
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
]
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
return res;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
return null;
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
module.exports.lastNDays = (filter) => {
|
|
555
|
+
if (!!filter.field_id) {
|
|
556
|
+
if (isNaN(filter.value)) {
|
|
557
|
+
return null;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const today = moment()
|
|
561
|
+
.startOf('day');
|
|
562
|
+
|
|
563
|
+
const lastNDays = moment()
|
|
564
|
+
.subtract(filter.value, 'd')
|
|
565
|
+
.endOf('day');
|
|
566
|
+
|
|
567
|
+
const res = {
|
|
568
|
+
bool: {
|
|
569
|
+
must: [
|
|
570
|
+
{
|
|
571
|
+
nested: {
|
|
572
|
+
path: 'fields',
|
|
573
|
+
query: {
|
|
574
|
+
bool: {
|
|
575
|
+
must: [
|
|
576
|
+
{
|
|
577
|
+
term: {
|
|
578
|
+
'fields.id': {
|
|
579
|
+
value: filter.field_id
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
range: {
|
|
585
|
+
'fields.number': {
|
|
586
|
+
lt: today.valueOf(),
|
|
587
|
+
gt: lastNDays.valueOf()
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
]
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
]
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
console.log(JSON.stringify(res, null, 2));
|
|
601
|
+
return res;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
return null;
|
|
605
|
+
};
|
|
606
|
+
|
|
498
607
|
module.exports.isBeforeIncludeParam = (filter) => {
|
|
499
608
|
if (!!filter.field_id) {
|
|
500
609
|
let param;
|
|
@@ -28,12 +28,15 @@ module.exports = (filter) => {
|
|
|
28
28
|
return module.exports.isAfterIncludeParam(filter);
|
|
29
29
|
case 'between':
|
|
30
30
|
return module.exports.isBetween(filter);
|
|
31
|
+
case 'next_n_days':
|
|
32
|
+
return module.exports.nextNDays(filter);
|
|
33
|
+
case 'last_n_days':
|
|
34
|
+
return module.exports.lastNDays(filter);
|
|
31
35
|
default:
|
|
32
36
|
return null;
|
|
33
37
|
}
|
|
34
38
|
};
|
|
35
39
|
|
|
36
|
-
|
|
37
40
|
module.exports.containsAny = (filter) => {
|
|
38
41
|
/**
|
|
39
42
|
* Field type is for custom columns
|
|
@@ -291,6 +294,61 @@ module.exports.isAfter = (filter) => {
|
|
|
291
294
|
};
|
|
292
295
|
};
|
|
293
296
|
|
|
297
|
+
module.exports.nextNDays = (filter) => {
|
|
298
|
+
if (isNaN(filter.value)) {
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const today = moment()
|
|
303
|
+
.startOf('day');
|
|
304
|
+
|
|
305
|
+
const nextNDays = moment()
|
|
306
|
+
.add(filter.value, 'd')
|
|
307
|
+
.endOf('day');
|
|
308
|
+
|
|
309
|
+
return {
|
|
310
|
+
range: {
|
|
311
|
+
[filter.type]: {
|
|
312
|
+
gt: today.valueOf(),
|
|
313
|
+
lt: nextNDays.valueOf()
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
module.exports.lastNDays = (filter) => {
|
|
320
|
+
if (isNaN(filter.value)) {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const today = moment()
|
|
325
|
+
.startOf('day');
|
|
326
|
+
|
|
327
|
+
const lastNDays = moment()
|
|
328
|
+
.subtract(filter.value, 'd')
|
|
329
|
+
.endOf('day');
|
|
330
|
+
|
|
331
|
+
const info = {
|
|
332
|
+
today: {
|
|
333
|
+
format: today.format('YYYY-MM-DD'),
|
|
334
|
+
value: today.valueOf()
|
|
335
|
+
},
|
|
336
|
+
lastNDays: {
|
|
337
|
+
format: lastNDays.format('YYYY-MM-DD'),
|
|
338
|
+
value: lastNDays.valueOf()
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
return {
|
|
343
|
+
range: {
|
|
344
|
+
[filter.type]: {
|
|
345
|
+
lt: today.valueOf(),
|
|
346
|
+
gt: lastNDays.valueOf()
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
|
|
294
352
|
module.exports.isBeforeIncludeParam = (filter) => {
|
|
295
353
|
let param;
|
|
296
354
|
|
package/lib/fieldConditions.js
CHANGED
|
@@ -165,6 +165,14 @@ module.exports.conditions = {
|
|
|
165
165
|
{
|
|
166
166
|
label: 'Is Not Empty',
|
|
167
167
|
value: 'is_not_empty'
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
label: 'In The Next N Days',
|
|
171
|
+
value: 'next_n_days'
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
label: 'In The Last N Days',
|
|
175
|
+
value: 'last_n_days'
|
|
168
176
|
}
|
|
169
177
|
]
|
|
170
178
|
};
|