@plusscommunities/pluss-maintenance-aws-feedback 2.1.15-beta.1
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/createJob.js +136 -0
- package/createJobType.js +64 -0
- package/db/maintenance/addMaintenanceJob.js +105 -0
- package/db/maintenance/editMaintenanceJob.js +18 -0
- package/db/maintenance/getJobEmail.js +28 -0
- package/deleteJob.js +74 -0
- package/deleteJobType.js +54 -0
- package/editJob.js +83 -0
- package/editJobStatus.js +81 -0
- package/editJobType.js +76 -0
- package/editNote.js +136 -0
- package/feature.config.js +255 -0
- package/getData.js +49 -0
- package/getJob.js +14 -0
- package/getJobType.js +47 -0
- package/getJobTypes.js +85 -0
- package/getJobs.js +63 -0
- package/integration/IntegrationStrategy.js +50 -0
- package/integration/archibus/ArchibusStrategy.js +591 -0
- package/integration/index.js +27 -0
- package/jobChanged.js +127 -0
- package/package-lock.json +7662 -0
- package/package.json +64 -0
- package/requests/assignRequest.js +106 -0
- package/requests/getAssignees.js +40 -0
- package/requests/getRequest.js +89 -0
- package/requests/getRequests.js +106 -0
- package/requests/helper/hasRequestPermission.js +25 -0
- package/requests/helper/isValidAssignee.js +23 -0
- package/requests/updatePriority.js +46 -0
- package/scheduleJobImport.js +81 -0
- package/sendJobEmail.js +153 -0
- package/updateData.js +37 -0
- package/values.config.a.js +27 -0
- package/values.config.default.js +30 -0
- package/values.config.enquiry.js +223 -0
- package/values.config.feedback.js +195 -0
- package/values.config.forms.js +30 -0
- package/values.config.js +195 -0
- package/watchJobs.js +177 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const values = {
|
|
2
|
+
entityKey: "maintenancerequestForms",
|
|
3
|
+
serviceKey: "maintenanceForms",
|
|
4
|
+
updateKey: "jobsForms",
|
|
5
|
+
tableKeyJobTypes: "jobtypesForms",
|
|
6
|
+
tableKeyMaintenance: "maintenanceForms",
|
|
7
|
+
tableKeySupportTickets: "supportticketsForms",
|
|
8
|
+
tableNameJobTypes: "jobTypesForms",
|
|
9
|
+
tableNameMaintenance: "maintenanceForms",
|
|
10
|
+
tableNameSupportTickets: "supportticketsForms",
|
|
11
|
+
permissionMaintenanceTracking: "maintenanceTrackingForms",
|
|
12
|
+
permissionMaintenanceAssignment: "maintenanceAssignmentForms",
|
|
13
|
+
permissionMaintenanceTypes: "maintenanceTypesForms",
|
|
14
|
+
routeEntityPath: "/requestsHubForms/jobDetails/:id",
|
|
15
|
+
screenMaintenanceDetail: "requestDetailForms",
|
|
16
|
+
notificationMaintenanceJobAssigned: "MaintenanceJobAssignedForms",
|
|
17
|
+
notificationMaintenanceJobUnassigned: "MaintenanceJobUnassignedForms",
|
|
18
|
+
activityAddMaintenanceJob: "AddMaintenanceJobForms",
|
|
19
|
+
activityDeleteMaintenanceJob: "DeleteMaintenanceJobForms",
|
|
20
|
+
activityEditMaintenanceJob: "EditMaintenanceJobForms",
|
|
21
|
+
activityMaintenanceJobStatusChanged: "MaintenanceJobStatusChangedForms",
|
|
22
|
+
activityAddMaintenanceNote: "AddMaintenanceNoteForms",
|
|
23
|
+
activityDeleteMaintenanceNote: "DeleteMaintenanceNoteForms",
|
|
24
|
+
activityEditMaintenanceNote: "EditMaintenanceNoteForms",
|
|
25
|
+
textJobEmailTitle: "Form Submission",
|
|
26
|
+
allowGeneralType: false,
|
|
27
|
+
defaultJobTypes: [],
|
|
28
|
+
triggerMaintenanceStatusChanged: "MaintenanceStatusChangedForms",
|
|
29
|
+
};
|
|
30
|
+
exports.values = values;
|
package/values.config.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
const values = {
|
|
2
|
+
entityKey: "maintenancerequestFeedback",
|
|
3
|
+
serviceKey: "maintenanceFeedback",
|
|
4
|
+
updateKey: "jobsFeedback",
|
|
5
|
+
tableKeyJobTypes: "jobtypesFeedback",
|
|
6
|
+
tableKeyMaintenance: "maintenanceFeedback",
|
|
7
|
+
tableKeySupportTickets: "supportticketsFeedback",
|
|
8
|
+
tableNameJobTypes: "jobTypesFeedback",
|
|
9
|
+
tableNameMaintenance: "maintenanceFeedback",
|
|
10
|
+
tableNameSupportTickets: "supportticketsFeedback",
|
|
11
|
+
permissionMaintenanceTracking: "maintenanceTrackingFeedback",
|
|
12
|
+
permissionMaintenanceAssignment: "maintenanceAssignmentFeedback",
|
|
13
|
+
permissionMaintenanceTypes: "maintenanceTypesFeedback",
|
|
14
|
+
routeEntityPath: "/requestsHubFeedback/jobDetails/:id",
|
|
15
|
+
screenMaintenanceDetail: "requestDetailFeedback",
|
|
16
|
+
notificationMaintenanceJobAssigned: "MaintenanceJobAssignedFeedback",
|
|
17
|
+
notificationMaintenanceJobUnassigned: "MaintenanceJobUnassignedFeedback",
|
|
18
|
+
activityAddMaintenanceJob: "AddMaintenanceJobFeedback",
|
|
19
|
+
activityDeleteMaintenanceJob: "DeleteMaintenanceJobFeedback",
|
|
20
|
+
activityEditMaintenanceJob: "EditMaintenanceJobFeedback",
|
|
21
|
+
activityMaintenanceJobStatusChanged: "MaintenanceJobStatusChangedFeedback",
|
|
22
|
+
activityAddMaintenanceNote: "AddMaintenanceNoteFeedback",
|
|
23
|
+
activityDeleteMaintenanceNote: "DeleteMaintenanceNoteFeedback",
|
|
24
|
+
activityEditMaintenanceNote: "EditMaintenanceNoteFeedback",
|
|
25
|
+
textJobEmailTitle: "Feedback Submission",
|
|
26
|
+
allowGeneralType: false,
|
|
27
|
+
defaultJobTypes: [
|
|
28
|
+
{
|
|
29
|
+
customFields: [
|
|
30
|
+
{
|
|
31
|
+
isTitle: false,
|
|
32
|
+
label: "What is the feedback about?",
|
|
33
|
+
mandatory: true,
|
|
34
|
+
type: "text",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
isTitle: false,
|
|
38
|
+
label: "Feedback details",
|
|
39
|
+
mandatory: true,
|
|
40
|
+
placeHolder:
|
|
41
|
+
"Record specific details related to your feedback. Include dates, names, other relevant information in the order they happened",
|
|
42
|
+
type: "text",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
isTitle: false,
|
|
46
|
+
label: "Desired outcome",
|
|
47
|
+
mandatory: false,
|
|
48
|
+
placeHolder:
|
|
49
|
+
"Describe the outcome you would like to see achieved as a result of the feedback you have provided.",
|
|
50
|
+
type: "text",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
isTitle: false,
|
|
54
|
+
label: "Thanks for taking the time to share your feedback with us.",
|
|
55
|
+
mandatory: false,
|
|
56
|
+
type: "staticText",
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
description:
|
|
60
|
+
"Use this form to provide general feedback that is not a specific complaint or compliment",
|
|
61
|
+
email: "feedback@plusscommunities.com",
|
|
62
|
+
hasCustomFields: true,
|
|
63
|
+
level: 1,
|
|
64
|
+
typeName: "General Feedback",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
customFields: [
|
|
68
|
+
{
|
|
69
|
+
isTitle: false,
|
|
70
|
+
label: "What is the complaint about?",
|
|
71
|
+
mandatory: true,
|
|
72
|
+
type: "checkbox",
|
|
73
|
+
values: [
|
|
74
|
+
"An employee",
|
|
75
|
+
"Another community member",
|
|
76
|
+
"A specific incident",
|
|
77
|
+
"Service delivery",
|
|
78
|
+
"A facility",
|
|
79
|
+
"An Activity",
|
|
80
|
+
"Other",
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
isTitle: false,
|
|
85
|
+
label: "Complaint details",
|
|
86
|
+
mandatory: true,
|
|
87
|
+
placeHolder:
|
|
88
|
+
"Please provide the details of your complaint in this section. Include dates, names, other relevant information in the order they happened",
|
|
89
|
+
type: "text",
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
isTitle: false,
|
|
93
|
+
label: "Action required",
|
|
94
|
+
mandatory: true,
|
|
95
|
+
placeHolder:
|
|
96
|
+
"Please describe what action, if any, you would like the organisation to take in relation to this matter",
|
|
97
|
+
type: "text",
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
isTitle: false,
|
|
101
|
+
label: "Have you raised this complaint previously",
|
|
102
|
+
mandatory: true,
|
|
103
|
+
type: "yn",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
isTitle: false,
|
|
107
|
+
label:
|
|
108
|
+
"If yes, please provide details of who you complained to, when and how (phone, email, form)",
|
|
109
|
+
mandatory: false,
|
|
110
|
+
type: "text",
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
isTitle: false,
|
|
114
|
+
label:
|
|
115
|
+
"If you have any supporting documentation (e.g. emails, letters, receipts) for your complaint, please attach the files below. If you do not have the documentation right now, you can email us.",
|
|
116
|
+
mandatory: false,
|
|
117
|
+
type: "document",
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
isTitle: false,
|
|
121
|
+
label:
|
|
122
|
+
"Declaration . I declare that the information supplied by me is, to the best of my knowledge, true and correct. ",
|
|
123
|
+
mandatory: true,
|
|
124
|
+
type: "yn",
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
isTitle: false,
|
|
128
|
+
label:
|
|
129
|
+
"I agree that the information provided (except for demographic data) may, if necessary, be revealed to the organisation in correspondence or investigations concerning this complaint or referred to another authority for their appropriate action should the matter fall outside this department's jurisdiction",
|
|
130
|
+
mandatory: true,
|
|
131
|
+
type: "yn",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
isTitle: false,
|
|
135
|
+
label:
|
|
136
|
+
"If your complaint is resolved after lodgement of this form, please advise us at as soon as possible.",
|
|
137
|
+
mandatory: false,
|
|
138
|
+
type: "staticText",
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
description: "Use this form to provide a complaint to the organisation",
|
|
142
|
+
email: "example@plusscommunities.com",
|
|
143
|
+
hasCustomFields: true,
|
|
144
|
+
level: 1,
|
|
145
|
+
typeName: "Complaint",
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
customFields: [
|
|
149
|
+
{
|
|
150
|
+
isTitle: false,
|
|
151
|
+
label: "What is this compliment about?",
|
|
152
|
+
mandatory: true,
|
|
153
|
+
type: "multichoice",
|
|
154
|
+
values: [
|
|
155
|
+
"An employee",
|
|
156
|
+
"A facility",
|
|
157
|
+
"Another community member",
|
|
158
|
+
"A facility",
|
|
159
|
+
"A service",
|
|
160
|
+
"An activity",
|
|
161
|
+
"Other",
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
isTitle: false,
|
|
166
|
+
label: "Compliment details",
|
|
167
|
+
mandatory: true,
|
|
168
|
+
placeHolder: "Please explain your compliment in detail",
|
|
169
|
+
type: "text",
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
isTitle: false,
|
|
173
|
+
label:
|
|
174
|
+
"Please describe what action, if any, you would like us to take in relation to this compliment",
|
|
175
|
+
mandatory: false,
|
|
176
|
+
type: "text",
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
isTitle: false,
|
|
180
|
+
label:
|
|
181
|
+
"Thanks for taking the time to record your compliment. It is always appreciated.",
|
|
182
|
+
mandatory: false,
|
|
183
|
+
type: "staticText",
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
description: "Use this form to record a compliment",
|
|
187
|
+
email: "example@pluss.com",
|
|
188
|
+
hasCustomFields: true,
|
|
189
|
+
level: 1,
|
|
190
|
+
typeName: "Compliment",
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
triggerMaintenanceStatusChanged: "MaintenanceStatusChangedFeedback",
|
|
194
|
+
};
|
|
195
|
+
exports.values = values;
|
package/watchJobs.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
const moment = require("moment");
|
|
2
|
+
const _ = require("lodash");
|
|
3
|
+
const scanRefRecursive = require("@plusscommunities/pluss-core-aws/db/common/scanRefRecursive");
|
|
4
|
+
const logAnalyticsActivity = require("@plusscommunities/pluss-core-aws/db/analytics/logAnalyticsActivity");
|
|
5
|
+
const checkActivityExists = require("@plusscommunities/pluss-core-aws/db/analytics/checkActivityExists");
|
|
6
|
+
const updateRef = require("@plusscommunities/pluss-core-aws/db/common/updateRef");
|
|
7
|
+
const editRef = require("@plusscommunities/pluss-core-aws/db/common/editRef");
|
|
8
|
+
const getRef = require("@plusscommunities/pluss-core-aws/db/common/getRef");
|
|
9
|
+
const { getRowId, log } = require("@plusscommunities/pluss-core-aws/helper");
|
|
10
|
+
const getUserPreview = require("@plusscommunities/pluss-core-aws/helper/getUserPreview");
|
|
11
|
+
const { values } = require("./values.config");
|
|
12
|
+
|
|
13
|
+
const checkFixCompleted = async (job) => {
|
|
14
|
+
const logId = log("checkFixCompleted", "Input", job.id);
|
|
15
|
+
if (job.status !== "Completed") {
|
|
16
|
+
log("checkFixCompleted", "Incomplete", job.status);
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// find entry in history to determine who completed and at what time
|
|
21
|
+
let userId;
|
|
22
|
+
let time = job.lastActivity;
|
|
23
|
+
if (!_.isEmpty(job.history)) {
|
|
24
|
+
const entry = _.findLast(job.history, (e) => {
|
|
25
|
+
return e.status === "Completed";
|
|
26
|
+
});
|
|
27
|
+
if (entry) {
|
|
28
|
+
if (entry.user && entry.user.id) {
|
|
29
|
+
userId = entry.user.id;
|
|
30
|
+
}
|
|
31
|
+
time = entry.timestamp;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const user = await getUserPreview(userId);
|
|
35
|
+
|
|
36
|
+
// add old log
|
|
37
|
+
await logAnalyticsActivity(
|
|
38
|
+
"RequestCompleted",
|
|
39
|
+
values.entityKey,
|
|
40
|
+
job.site,
|
|
41
|
+
user,
|
|
42
|
+
job.id,
|
|
43
|
+
null,
|
|
44
|
+
moment(time).valueOf()
|
|
45
|
+
);
|
|
46
|
+
log("checkFixCompleted", "Logged", true, logId);
|
|
47
|
+
|
|
48
|
+
// tell system to aggregate this date again
|
|
49
|
+
const date = moment(time).local().format("DD-MM-YYYY");
|
|
50
|
+
log("checkFixCompleted", "QueueingDate", date, logId);
|
|
51
|
+
await updateRef("analyticsqueue", {
|
|
52
|
+
Id: getRowId(job.site, date),
|
|
53
|
+
Site: job.site,
|
|
54
|
+
Date: date,
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const fixActivityLog = async (job, startTime) => {
|
|
59
|
+
const now = moment().unix();
|
|
60
|
+
if (now - startTime > 240) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// check whether it's already been logged
|
|
65
|
+
const exists = await checkActivityExists(job.id, values.entityKey, "Request");
|
|
66
|
+
const logId = log("fixActivityLog", "exists", exists);
|
|
67
|
+
|
|
68
|
+
if (!exists) {
|
|
69
|
+
const user = await getUserPreview(job.userID);
|
|
70
|
+
|
|
71
|
+
// add old log
|
|
72
|
+
await logAnalyticsActivity(
|
|
73
|
+
"Request",
|
|
74
|
+
values.entityKey,
|
|
75
|
+
job.site,
|
|
76
|
+
user,
|
|
77
|
+
job.id,
|
|
78
|
+
null,
|
|
79
|
+
moment(job.createdTime).valueOf()
|
|
80
|
+
);
|
|
81
|
+
log("fixActivityLog", "Logged", true, logId);
|
|
82
|
+
|
|
83
|
+
// tell system to aggregate this date again
|
|
84
|
+
const date = moment(job.createdTime).local().format("DD-MM-YYYY");
|
|
85
|
+
log("fixActivityLog", "QueueingDate", date, logId);
|
|
86
|
+
await updateRef("analyticsqueue", {
|
|
87
|
+
Id: getRowId(job.site, date),
|
|
88
|
+
Site: job.site,
|
|
89
|
+
Date: date,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// check whether to log activity for the job's completion
|
|
93
|
+
await checkFixCompleted(job);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// update entry to show it's been logged
|
|
97
|
+
await editRef(values.tableNameMaintenance, "id", job.id, {
|
|
98
|
+
ActivityLogged: true,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return true;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const checkFixLog = async (startTime) => {
|
|
105
|
+
// Check whether all posts have been logged
|
|
106
|
+
const logId = log("checkFixLog", "StartTime", startTime);
|
|
107
|
+
const stringSite = "plussSpace";
|
|
108
|
+
const stringId = `JobActivityLogged`;
|
|
109
|
+
const stringRowId = getRowId(stringSite, stringId);
|
|
110
|
+
try {
|
|
111
|
+
const string = await getRef("strings", "RowId", stringRowId);
|
|
112
|
+
if (string && string.Value === "true") {
|
|
113
|
+
log("checkFixLog", "ActivityLogged", true, logId);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
} catch (e) {
|
|
117
|
+
// ignore error
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Scans the DynamoDB table and fetch all items. The parameters describe which attributes to get.
|
|
121
|
+
const items = await scanRefRecursive(values.tableNameMaintenance, {
|
|
122
|
+
ProjectionExpression:
|
|
123
|
+
"#id, site, createdTime, #status, lastActivity, history, ActivityLogged",
|
|
124
|
+
ExpressionAttributeNames: {
|
|
125
|
+
"#id": "id",
|
|
126
|
+
"#status": "status",
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
log(
|
|
130
|
+
"checkFixLog",
|
|
131
|
+
"FetchedItemsCount",
|
|
132
|
+
{
|
|
133
|
+
count: items.length,
|
|
134
|
+
},
|
|
135
|
+
logId
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
// Filters out items which have already had the activity log operation applied.
|
|
139
|
+
const itemsToProcess = items.filter((item) => !item.ActivityLogged);
|
|
140
|
+
log(
|
|
141
|
+
"checkFixLog",
|
|
142
|
+
"ItemsToProcessCount",
|
|
143
|
+
{ count: itemsToProcess.length },
|
|
144
|
+
logId
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
// Finished logging old entries. Save to avoid continuous full scans of the table.
|
|
148
|
+
if (_.isEmpty(itemsToProcess)) {
|
|
149
|
+
const entry = {
|
|
150
|
+
Site: stringSite,
|
|
151
|
+
StringId: stringId,
|
|
152
|
+
Value: "true",
|
|
153
|
+
RowId: stringRowId,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
await updateRef("strings", entry);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// The loop goes through the remaining items and applies the fixActivityLog operation on each item.
|
|
160
|
+
// If the operation fails on an item, it logs the error but continues with the remaining items.
|
|
161
|
+
for (let item of itemsToProcess) {
|
|
162
|
+
// try {
|
|
163
|
+
await fixActivityLog(item, startTime);
|
|
164
|
+
log("checkFixLog", "SuccessFixActivityLog", { id: item.Id }, logId);
|
|
165
|
+
// } catch (err) {
|
|
166
|
+
// log("checkFixLog", `Error:${item.Id}`, err, logId);
|
|
167
|
+
// }
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
log("checkFixLog", "End", "All items processed", logId);
|
|
171
|
+
return true;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
module.exports.watchJobs = async (event, context, callback) => {
|
|
175
|
+
const startTime = moment().unix();
|
|
176
|
+
await checkFixLog(startTime);
|
|
177
|
+
};
|