@outliant/sunrise-utils 1.1.11 → 1.1.13
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 +16 -0
- package/helpers/projectFilter/index.js +19 -0
- package/helpers/projectFilter/isPausedFilter.js +41 -0
- package/helpers/sortScript.js +17 -0
- package/helpers/taskFilter/index.js +19 -0
- package/helpers/taskFilter/isPausedFilter.js +122 -0
- package/lib/projectPipeline.js +30 -15
- package/lib/taskPipeline.js +4 -0
- package/package.json +1 -1
- package/test/lib/taskPipeline.spec.js +71 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,10 +4,26 @@ 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.1.13](https://github.com/outliant/sunrise-utils/compare/1.1.12...1.1.13)
|
|
8
|
+
|
|
9
|
+
- chore: change equal condition [`#18`](https://github.com/outliant/sunrise-utils/pull/18)
|
|
10
|
+
- chore: update isPaused filter [`99d882d`](https://github.com/outliant/sunrise-utils/commit/99d882d74cb7fb6d7aba3048a2328343017ca512)
|
|
11
|
+
|
|
12
|
+
#### [1.1.12](https://github.com/outliant/sunrise-utils/compare/1.1.11...1.1.12)
|
|
13
|
+
|
|
14
|
+
> 7 November 2023
|
|
15
|
+
|
|
16
|
+
- chore: add isPaused [`#17`](https://github.com/outliant/sunrise-utils/pull/17)
|
|
17
|
+
- chore: add unit test for is_paused [`aa5fada`](https://github.com/outliant/sunrise-utils/commit/aa5fada660f2883004a1a72ddb0603f412dec18e)
|
|
18
|
+
- chore(release): 1.1.12 [`56f3083`](https://github.com/outliant/sunrise-utils/commit/56f30836a6b021e0d57cfabf9541b063ddb92afd)
|
|
19
|
+
|
|
7
20
|
#### [1.1.11](https://github.com/outliant/sunrise-utils/compare/1.1.10...1.1.11)
|
|
8
21
|
|
|
22
|
+
> 18 October 2023
|
|
23
|
+
|
|
9
24
|
- chore: implement case insensitive search for id [`#16`](https://github.com/outliant/sunrise-utils/pull/16)
|
|
10
25
|
- chore: add test for projectPipeline utils [`b35d394`](https://github.com/outliant/sunrise-utils/commit/b35d394d98713d01c1149ef1a36f6c7c2cf4adab)
|
|
26
|
+
- chore(release): 1.1.11 [`e88579a`](https://github.com/outliant/sunrise-utils/commit/e88579ab043a70ca5901c0fbeb4cdda58f9cccd2)
|
|
11
27
|
|
|
12
28
|
#### [1.1.10](https://github.com/outliant/sunrise-utils/compare/1.1.9...1.1.10)
|
|
13
29
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const buildRegionFilter = require('./regionFilter');
|
|
2
2
|
const buildCriticalPathFilter = require('./criticalPathFilter');
|
|
3
3
|
const buildOnHoldFilter = require('./onHoldFilter');
|
|
4
|
+
const buildIsPausedFilter = require('./isPausedFilter');
|
|
4
5
|
const buildIsGeneratedFilter = require('./isGeneratedFilter');
|
|
5
6
|
const buildTagFilter = require('./tagFilter');
|
|
6
7
|
const buildProjectFieldFilter = require('./projectFieldFilter');
|
|
@@ -32,6 +33,22 @@ module.exports.defaultCustomColumns = [
|
|
|
32
33
|
type: 'on_hold',
|
|
33
34
|
field_type: 'select'
|
|
34
35
|
},
|
|
36
|
+
{
|
|
37
|
+
name: 'Is Paused',
|
|
38
|
+
value: 'is_paused',
|
|
39
|
+
type: 'is_paused',
|
|
40
|
+
field_type: 'select',
|
|
41
|
+
options: [
|
|
42
|
+
{
|
|
43
|
+
label: 'Yes',
|
|
44
|
+
value: 'Yes'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: 'No',
|
|
48
|
+
value: 'No'
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
35
52
|
{
|
|
36
53
|
name: 'Is Generated',
|
|
37
54
|
value: 'is_generated',
|
|
@@ -93,6 +110,8 @@ module.exports.buildProjectPipelineFilter = (filter) => {
|
|
|
93
110
|
return buildCriticalPathFilter(filter);
|
|
94
111
|
case 'on_hold':
|
|
95
112
|
return buildOnHoldFilter(filter);
|
|
113
|
+
case 'is_paused':
|
|
114
|
+
return buildIsPausedFilter(filter);
|
|
96
115
|
case 'is_generated':
|
|
97
116
|
return buildIsGeneratedFilter(filter);
|
|
98
117
|
case 'dealPropertyMappings':
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
module.exports = (filter) => {
|
|
2
|
+
switch (filter.condition) {
|
|
3
|
+
case 'is_equal':
|
|
4
|
+
return module.exports.isEqual();
|
|
5
|
+
case 'not_equal':
|
|
6
|
+
return module.exports.isNotEqual();
|
|
7
|
+
default:
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
module.exports.isEqual = () => {
|
|
13
|
+
return {
|
|
14
|
+
match: {
|
|
15
|
+
is_paused: true
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
module.exports.isNotEqual = () => {
|
|
21
|
+
return {
|
|
22
|
+
bool: {
|
|
23
|
+
should: [
|
|
24
|
+
{
|
|
25
|
+
match: {
|
|
26
|
+
is_paused: false
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
bool: {
|
|
31
|
+
must_not: {
|
|
32
|
+
exists: {
|
|
33
|
+
field: 'is_paused'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
};
|
package/helpers/sortScript.js
CHANGED
|
@@ -222,6 +222,23 @@ module.exports.criticalPathStage = (order) => {
|
|
|
222
222
|
};
|
|
223
223
|
};
|
|
224
224
|
|
|
225
|
+
module.exports.isPaused = (order) => {
|
|
226
|
+
return {
|
|
227
|
+
_script: {
|
|
228
|
+
type: 'number',
|
|
229
|
+
script: {
|
|
230
|
+
lang: 'painless',
|
|
231
|
+
source: `
|
|
232
|
+
return doc['is_paused'].empty
|
|
233
|
+
? 0
|
|
234
|
+
: doc['is_paused'].value ? 1 : 0;
|
|
235
|
+
`
|
|
236
|
+
},
|
|
237
|
+
order
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
|
|
225
242
|
module.exports.projectId = (order) => {
|
|
226
243
|
return {
|
|
227
244
|
_script: {
|
|
@@ -5,6 +5,7 @@ const buildRegionFilter = require('./regionFilter');
|
|
|
5
5
|
const buildTaskFieldFilter = require('./taskFieldFilter');
|
|
6
6
|
const buildCriticalPathFilter = require('./criticalPathFilter');
|
|
7
7
|
const buildOnHoldFilter = require('./onHoldFilter');
|
|
8
|
+
const buildIsPausedFilter = require('./isPausedFilter');
|
|
8
9
|
const buildDaysToCompleteFilter = require('./daysToComplete');
|
|
9
10
|
const buildAgeColorFilter = require('./buildAgeColorFilter');
|
|
10
11
|
const buildProjectFieldFilter = require('../projectFilter/projectFieldFilter');
|
|
@@ -121,6 +122,22 @@ module.exports.defaultCustomColumns = [
|
|
|
121
122
|
}
|
|
122
123
|
]
|
|
123
124
|
},
|
|
125
|
+
{
|
|
126
|
+
name: 'Is Paused',
|
|
127
|
+
value: 'is_paused',
|
|
128
|
+
type: 'is_paused',
|
|
129
|
+
field_type: 'select',
|
|
130
|
+
options: [
|
|
131
|
+
{
|
|
132
|
+
label: 'Yes',
|
|
133
|
+
value: 'Yes'
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
label: 'No',
|
|
137
|
+
value: 'No'
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
},
|
|
124
141
|
{
|
|
125
142
|
name: 'Last Comment',
|
|
126
143
|
value: 'last_comment',
|
|
@@ -235,6 +252,8 @@ module.exports.buildTaskPipelineFilter = (filter) => {
|
|
|
235
252
|
return buildCriticalPathFilter(filter);
|
|
236
253
|
case 'on_hold':
|
|
237
254
|
return buildOnHoldFilter(filter);
|
|
255
|
+
case 'is_paused':
|
|
256
|
+
return buildIsPausedFilter(filter);
|
|
238
257
|
case 'days_to_complete':
|
|
239
258
|
return buildDaysToCompleteFilter(filter);
|
|
240
259
|
// Always expected as is_equal condition
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
const splitString = require('../splitString');
|
|
2
|
+
|
|
3
|
+
module.exports = (filter) => {
|
|
4
|
+
switch (filter.condition) {
|
|
5
|
+
case 'is_empty':
|
|
6
|
+
return module.exports.isEmpty();
|
|
7
|
+
case 'is_not_empty':
|
|
8
|
+
return module.exports.isNotEmpty();
|
|
9
|
+
case 'is_equal':
|
|
10
|
+
return module.exports.isEqual(filter);
|
|
11
|
+
case 'not_equal':
|
|
12
|
+
return module.exports.isNotEqual(filter);
|
|
13
|
+
case 'is_any_of':
|
|
14
|
+
return module.exports.isAnyOf(filter); // if is any, means all tasks that have value
|
|
15
|
+
default:
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
module.exports.isEmpty = () => {
|
|
21
|
+
return {
|
|
22
|
+
bool: {
|
|
23
|
+
must_not: [
|
|
24
|
+
{
|
|
25
|
+
exists: {
|
|
26
|
+
field: 'is_paused'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
module.exports.isNotEmpty = () => {
|
|
35
|
+
return {
|
|
36
|
+
bool: {
|
|
37
|
+
must: [
|
|
38
|
+
{
|
|
39
|
+
exists: {
|
|
40
|
+
field: 'is_paused'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
module.exports.isEqual = (filter) => {
|
|
49
|
+
const isYes = filter.value === 'Yes';
|
|
50
|
+
|
|
51
|
+
if (isYes) {
|
|
52
|
+
return {
|
|
53
|
+
bool: {
|
|
54
|
+
must: [
|
|
55
|
+
{
|
|
56
|
+
term: {
|
|
57
|
+
is_paused: {
|
|
58
|
+
value: true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
bool: {
|
|
69
|
+
should: [
|
|
70
|
+
{
|
|
71
|
+
match: {
|
|
72
|
+
is_paused: false
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
bool: {
|
|
77
|
+
must_not: {
|
|
78
|
+
exists: {
|
|
79
|
+
field: 'is_paused'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
module.exports.isNotEqual = (filter) => {
|
|
90
|
+
return {
|
|
91
|
+
bool: {
|
|
92
|
+
must_not: [
|
|
93
|
+
module.exports.isEqual(filter)
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
module.exports.isAnyOf = (filter) => {
|
|
100
|
+
let value = filter.value;
|
|
101
|
+
|
|
102
|
+
if (typeof value === 'string') {
|
|
103
|
+
value = splitString(value);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const should = [];
|
|
107
|
+
value.forEach((x) => {
|
|
108
|
+
should.push({
|
|
109
|
+
term: {
|
|
110
|
+
is_paused: {
|
|
111
|
+
value: x === 'Yes'
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
bool: {
|
|
119
|
+
should
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
};
|
package/lib/projectPipeline.js
CHANGED
|
@@ -89,21 +89,36 @@ class ProjectPipeline {
|
|
|
89
89
|
if (sortByMultiple.length > 0) {
|
|
90
90
|
sortByMultiple.forEach((s, i) => {
|
|
91
91
|
const sort = sortMultiple[i] || 'desc';
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
92
|
+
|
|
93
|
+
switch (true) {
|
|
94
|
+
case isUuid(s):
|
|
95
|
+
projectPipelinesSort.push(sortScript.projectFieldNumeric(sort, s));
|
|
96
|
+
projectPipelinesSort.push(sortScript.projectFieldText(sort, s));
|
|
97
|
+
break;
|
|
98
|
+
|
|
99
|
+
case s === 'region':
|
|
100
|
+
projectPipelinesSort.push(sortScript.region(sort));
|
|
101
|
+
break;
|
|
102
|
+
|
|
103
|
+
case s === 'criticalPathStage':
|
|
104
|
+
projectPipelinesSort.push(sortScript.criticalPathStage(sort));
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
case s === 'is_paused':
|
|
108
|
+
projectPipelinesSort.push(sortScript.isPaused(sort));
|
|
109
|
+
break;
|
|
110
|
+
|
|
111
|
+
case s === 'name':
|
|
112
|
+
projectPipelinesSort.push({
|
|
113
|
+
'name.raw': { order: sort, missing: '_last' }
|
|
114
|
+
});
|
|
115
|
+
break;
|
|
116
|
+
|
|
117
|
+
default:
|
|
118
|
+
projectPipelinesSort.push({
|
|
119
|
+
[s]: { order: sort, missing: '_last' }
|
|
120
|
+
});
|
|
121
|
+
break;
|
|
107
122
|
}
|
|
108
123
|
});
|
|
109
124
|
}
|
package/lib/taskPipeline.js
CHANGED
|
@@ -104,6 +104,10 @@ class TaskPipeline {
|
|
|
104
104
|
taskPipelinesSort.push(sortScript.region(sort));
|
|
105
105
|
break;
|
|
106
106
|
|
|
107
|
+
case s === 'is_paused':
|
|
108
|
+
taskPipelinesSort.push(sortScript.isPaused(sort));
|
|
109
|
+
break;
|
|
110
|
+
|
|
107
111
|
case s === 'owner' :
|
|
108
112
|
case s === 'completed_by' :
|
|
109
113
|
taskPipelinesSort.push(sortScript.owner(sort));
|
package/package.json
CHANGED
|
@@ -125,6 +125,66 @@ describe('taskPipeline', function () {
|
|
|
125
125
|
done();
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
+
it('should not add default is_paused filter if present', (done) => {
|
|
129
|
+
const filter = taskPipeline.buildFiltersQuery(
|
|
130
|
+
testOrgId,
|
|
131
|
+
testDepartmentId,
|
|
132
|
+
[
|
|
133
|
+
{
|
|
134
|
+
condition: 'is_equal',
|
|
135
|
+
field_id: '',
|
|
136
|
+
type: 'status',
|
|
137
|
+
field_type: 'select',
|
|
138
|
+
value: 'is_paused',
|
|
139
|
+
second_value: ''
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
expect(filter).to.deep.equal({
|
|
145
|
+
bool: {
|
|
146
|
+
must: [
|
|
147
|
+
{
|
|
148
|
+
term: {
|
|
149
|
+
organization_id: {
|
|
150
|
+
value: "test-org"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
term: {
|
|
156
|
+
department_id: {
|
|
157
|
+
value: "test-department"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
bool: {
|
|
163
|
+
should: [
|
|
164
|
+
{
|
|
165
|
+
term: {
|
|
166
|
+
on_hold: false
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
bool: {
|
|
171
|
+
must_not: {
|
|
172
|
+
exists: {
|
|
173
|
+
field: "on_hold"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
done();
|
|
186
|
+
});
|
|
187
|
+
|
|
128
188
|
it('should handle unknown filter', (done) => {
|
|
129
189
|
const filter = taskPipeline.buildFiltersQuery(
|
|
130
190
|
testOrgId,
|
|
@@ -233,7 +293,7 @@ describe('taskPipeline', function () {
|
|
|
233
293
|
{
|
|
234
294
|
sort: 'asc,asc,asc',
|
|
235
295
|
sortBy:
|
|
236
|
-
'region,owner,completed_by,status,critical_path_stage,project_id,ready_at,was_marked_incomplete,last_comment_date,38d423bf-fc24-4183-b8b7-15420c89e318,id'
|
|
296
|
+
'region,owner,completed_by,status,critical_path_stage,project_id,ready_at,was_marked_incomplete,last_comment_date,is_paused,38d423bf-fc24-4183-b8b7-15420c89e318,id'
|
|
237
297
|
},
|
|
238
298
|
[
|
|
239
299
|
{
|
|
@@ -355,6 +415,16 @@ describe('taskPipeline', function () {
|
|
|
355
415
|
order: "desc"
|
|
356
416
|
}
|
|
357
417
|
},
|
|
418
|
+
{
|
|
419
|
+
_script: {
|
|
420
|
+
type: "number",
|
|
421
|
+
script: {
|
|
422
|
+
lang: "painless",
|
|
423
|
+
source: "\n return doc['is_paused'].empty\n ? 0\n : doc['is_paused'].value ? 1 : 0;\n "
|
|
424
|
+
},
|
|
425
|
+
order: "desc"
|
|
426
|
+
}
|
|
427
|
+
},
|
|
358
428
|
{
|
|
359
429
|
_script: {
|
|
360
430
|
type: "number",
|