@plusscommunities/pluss-maintenance-aws-forms 2.1.41 → 2.1.42
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/feature.config.js
CHANGED
|
@@ -211,6 +211,7 @@ exports.serverless = {
|
|
|
211
211
|
{ name: "jobId", type: "S" },
|
|
212
212
|
{ name: "jobNo", type: "N" },
|
|
213
213
|
{ name: "userID", type: "S" },
|
|
214
|
+
{ name: "AssigneeId", type: "S" },
|
|
214
215
|
],
|
|
215
216
|
id: "id",
|
|
216
217
|
indexes: [
|
|
@@ -239,6 +240,13 @@ exports.serverless = {
|
|
|
239
240
|
{ name: "userID", type: "RANGE" },
|
|
240
241
|
],
|
|
241
242
|
},
|
|
243
|
+
{
|
|
244
|
+
name: "MaintenanceSiteAssigneeIndex",
|
|
245
|
+
keys: [
|
|
246
|
+
{ name: "site", type: "HASH" },
|
|
247
|
+
{ name: "AssigneeId", type: "RANGE" },
|
|
248
|
+
],
|
|
249
|
+
},
|
|
242
250
|
],
|
|
243
251
|
},
|
|
244
252
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plusscommunities/pluss-maintenance-aws-forms",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.42",
|
|
4
4
|
"description": "Extension package to enable maintenance on Pluss Communities Platform",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"gc": "node ../../tools/gc ./",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"copy:set": "run(){ target='\\@plusscommunities\\/pluss-maintenance-aws'; ext=${1:-default}; [ $ext == 'default' ] && replace=$target || replace=$target'-'$ext; echo 'Setting target to '$replace; test -f values.config.$ext.js && cp -f values.config.$ext.js values.config.js; sed -i '' -e 's/'$target'.*\"/'$replace'\"/g' package.json; }; run",
|
|
18
18
|
"copy:deploy": "for file in `ls ./values.config.*.js`; do dup=`echo $file | sed 's/.*values\\.config\\.\\(.*\\)\\.js/\\1/'`; npm run copy:set $dup; npm run deploy; done; npm run copy:set; npm run gs;",
|
|
19
19
|
"copy:betaupload": "npm run betapach; for file in `ls ./values.config.*.js`; do dup=`echo $file | sed 's/.*values\\.config\\.\\(.*\\)\\.js/\\1/'`; npm run copy:set $dup; npm run betaupload; done; npm run copy:set;",
|
|
20
|
-
"copy:upload": "
|
|
20
|
+
"copy:upload": "for file in `ls ./values.config.*.js`; do dup=`echo $file | sed 's/.*values\\.config\\.\\(.*\\)\\.js/\\1/'`; npm run copy:set $dup; npm run upload; done; npm run copy:set;",
|
|
21
21
|
"test": "jest tests -i"
|
|
22
22
|
},
|
|
23
23
|
"author": "Thorbjorn Kappel Davis",
|
package/requests/getRequests.js
CHANGED
|
@@ -5,6 +5,20 @@ const validateSiteAccess = require("@plusscommunities/pluss-core-aws/helper/auth
|
|
|
5
5
|
const indexQuery = require("@plusscommunities/pluss-core-aws/db/common/indexQuery");
|
|
6
6
|
const { values } = require("../values.config");
|
|
7
7
|
|
|
8
|
+
// Normalise legacy/null status to "Open" (null = very old jobs, "Unassigned" = pre-rename)
|
|
9
|
+
const STATUS_OPEN = "Open";
|
|
10
|
+
const normalizeStatus = (status) =>
|
|
11
|
+
!status || status === "Unassigned" ? STATUS_OPEN : status;
|
|
12
|
+
|
|
13
|
+
// HACK: Lax "complete" match handles minor label variations across sites
|
|
14
|
+
const isCompleted = (status) =>
|
|
15
|
+
status && status.toLowerCase().includes("complete");
|
|
16
|
+
|
|
17
|
+
// Priority defaults to "Low" when not set (not set on creation)
|
|
18
|
+
const DEFAULT_PRIORITY = "Low";
|
|
19
|
+
const normalizePriority = (priority) =>
|
|
20
|
+
priority == null ? DEFAULT_PRIORITY : priority;
|
|
21
|
+
|
|
8
22
|
module.exports = async (event) => {
|
|
9
23
|
const qParams = event.queryStringParameters;
|
|
10
24
|
const logId = log("getRequests", "Params", qParams);
|
|
@@ -59,6 +73,13 @@ module.exports = async (event) => {
|
|
|
59
73
|
":userId": userId,
|
|
60
74
|
},
|
|
61
75
|
};
|
|
76
|
+
|
|
77
|
+
// Use the assignee GSI when filtering by assignee (avoids fetching the entire site's jobs)
|
|
78
|
+
if (qParams.assignee && (authorised || assigneeTracking)) {
|
|
79
|
+
query.IndexName = "MaintenanceSiteAssigneeIndex";
|
|
80
|
+
query.KeyConditionExpression = "site = :site AND AssigneeId = :assigneeId";
|
|
81
|
+
query.ExpressionAttributeValues[":assigneeId"] = qParams.assignee;
|
|
82
|
+
}
|
|
62
83
|
log("getRequests", "query", query, logId);
|
|
63
84
|
|
|
64
85
|
// check whether pagination is applied
|
|
@@ -77,13 +98,17 @@ module.exports = async (event) => {
|
|
|
77
98
|
|
|
78
99
|
// filter on status
|
|
79
100
|
if (qParams.status) {
|
|
80
|
-
|
|
101
|
+
if (qParams.status === "Incomplete") {
|
|
102
|
+
jobs = jobs.filter((j) => !isCompleted(normalizeStatus(j.status)));
|
|
103
|
+
} else {
|
|
104
|
+
jobs = jobs.filter((j) => qParams.status.includes(normalizeStatus(j.status)));
|
|
105
|
+
}
|
|
81
106
|
log("getRequests", "FilteredOnStatus", jobs.length, logId);
|
|
82
107
|
}
|
|
83
108
|
|
|
84
|
-
// filter on priority
|
|
109
|
+
// filter on priority (normalise null to the default)
|
|
85
110
|
if (qParams.priority) {
|
|
86
|
-
jobs = jobs.filter((j) => qParams.priority.includes(j.priority));
|
|
111
|
+
jobs = jobs.filter((j) => qParams.priority.includes(normalizePriority(j.priority)));
|
|
87
112
|
log("getRequests", "FilterOnPriority", jobs.length, logId);
|
|
88
113
|
}
|
|
89
114
|
|
|
@@ -93,12 +118,6 @@ module.exports = async (event) => {
|
|
|
93
118
|
log("getRequests", "FilteredOnType", jobs.length, logId);
|
|
94
119
|
}
|
|
95
120
|
|
|
96
|
-
// filter on assignee (for users with tracking permission)
|
|
97
|
-
if (qParams.assignee) {
|
|
98
|
-
jobs = jobs.filter((j) => j.AssigneeId === qParams.assignee);
|
|
99
|
-
log("getRequests", "FilteredOnAssigneeFilter", jobs.length, logId);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
121
|
// filter to assigned jobs
|
|
103
122
|
if (!authorised && assigneeTracking) {
|
|
104
123
|
jobs = jobs.filter((j) => j.AssigneeId === userId || j.userID === userId);
|