@plusscommunities/pluss-maintenance-aws 1.2.9 → 1.2.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/db/maintenance/addMaintenanceJob.js +33 -14
- package/feature.config.js +8 -0
- package/package-lock.json +1 -1
- package/package.json +1 -1
|
@@ -63,20 +63,39 @@ module.exports = async (
|
|
|
63
63
|
requestToSave.id = uuid.v1();
|
|
64
64
|
requestToSave.createdTime = moment.utc().toISOString();
|
|
65
65
|
requestToSave.createdUnix = moment.utc().valueOf();
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
if (!requestToSave.jobId) {
|
|
67
|
+
const jobNoQ = {
|
|
68
|
+
IndexName: "MaintenanceSiteJobNoIndex",
|
|
69
|
+
KeyConditionExpression: "site = :site",
|
|
70
|
+
ExpressionAttributeValues: {
|
|
71
|
+
":site": requestToSave.site,
|
|
72
|
+
},
|
|
73
|
+
Limit: 1,
|
|
74
|
+
ScanIndexForward: false,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const queryRes = await indexQuery("maintenance", jobNoQ);
|
|
78
|
+
|
|
79
|
+
if (!_.isEmpty(queryRes.Items)) {
|
|
80
|
+
requestToSave.jobNo = queryRes.Items[0].jobNo + 1;
|
|
81
|
+
} else {
|
|
82
|
+
const query = {
|
|
83
|
+
IndexName: "MaintenanceSiteJobIdIndex",
|
|
84
|
+
KeyConditionExpression: "site = :site",
|
|
85
|
+
ExpressionAttributeValues: {
|
|
86
|
+
":site": requestToSave.site,
|
|
87
|
+
},
|
|
88
|
+
Limit: 1,
|
|
89
|
+
ScanIndexForward: false,
|
|
90
|
+
};
|
|
91
|
+
const { Items } = await indexQuery("maintenance", query);
|
|
92
|
+
requestToSave.jobNo =
|
|
93
|
+
!_.isEmpty(Items) && Items[0].jobId
|
|
94
|
+
? Number.parseInt(Items[0].jobId) + 1
|
|
95
|
+
: 0;
|
|
96
|
+
}
|
|
97
|
+
requestToSave.jobId = (requestToSave.jobNo || 0) + "";
|
|
98
|
+
}
|
|
80
99
|
|
|
81
100
|
await updateRef("maintenance", requestToSave);
|
|
82
101
|
return requestToSave.id;
|
package/feature.config.js
CHANGED
|
@@ -222,6 +222,7 @@ exports.serverless = {
|
|
|
222
222
|
{ name: "id", type: "S" },
|
|
223
223
|
{ name: "site", type: "S" },
|
|
224
224
|
{ name: "jobId", type: "S" },
|
|
225
|
+
{ name: "jobNo", type: "N" },
|
|
225
226
|
{ name: "userID", type: "S" },
|
|
226
227
|
],
|
|
227
228
|
id: "id",
|
|
@@ -237,6 +238,13 @@ exports.serverless = {
|
|
|
237
238
|
{ name: "jobId", type: "RANGE" },
|
|
238
239
|
],
|
|
239
240
|
},
|
|
241
|
+
{
|
|
242
|
+
name: "MaintenanceSiteJobNoIndex",
|
|
243
|
+
keys: [
|
|
244
|
+
{ name: "site", type: "HASH" },
|
|
245
|
+
{ name: "jobNo", type: "RANGE" },
|
|
246
|
+
],
|
|
247
|
+
},
|
|
240
248
|
{
|
|
241
249
|
name: "MaintenanceSiteUserIdIndex",
|
|
242
250
|
keys: [
|
package/package-lock.json
CHANGED