@openinc/parse-server-opendash 4.0.26 → 4.0.28

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.
@@ -80,8 +80,6 @@ async function init() {
80
80
  scheduleOrderStartedStatusCheck("0 * * * * *");
81
81
  (0, index_js_2.beforeSaveHook)(index_js_3.MES_Order, async (request) => {
82
82
  const { object, original, user } = request;
83
- if (!object.id)
84
- return;
85
83
  await (0, index_js_2.defaultHandler)(request);
86
84
  await (0, index_js_2.defaultAclHandler)(request, {
87
85
  allowCustomACL: true,
@@ -115,6 +113,7 @@ async function init() {
115
113
  const currentStatus = object.get("status");
116
114
  const start = object.get("start");
117
115
  const hasSource = !!object.get("source");
116
+ console.log("[MES] - beforeSaveHook: Current status is " + currentStatus + ", start is " + start + ", hasSource is " + hasSource);
118
117
  if (currentStatus !== "done" && currentStatus !== "canceled" && start) {
119
118
  const startMs = start.getTime();
120
119
  const nowMs = Date.now();
@@ -132,12 +131,17 @@ async function init() {
132
131
  (object.get("status") === "running" || object.get("status") === "planned")) {
133
132
  object.set("status", "done");
134
133
  }
134
+ console.log("[MES] - beforeSaveHook: Updated status is " + object.get("status"));
135
135
  if (object.get("status") === "running") {
136
+ console.log("[MES] - beforeSaveHook: Checking for running orders with same tag to update their duration to end them if necessary.");
136
137
  const runningOrdersQ = new node_1.default.Query(index_js_3.MES_Order);
137
138
  runningOrdersQ.equalTo("tag", object.get("tag"));
138
- runningOrdersQ.notEqualTo("objectId", object.id);
139
+ if (object.id) {
140
+ runningOrdersQ.notEqualTo("objectId", object.id);
141
+ }
139
142
  runningOrdersQ.equalTo("status", "running");
140
143
  const runningOrders = await runningOrdersQ.find({ useMasterKey: true });
144
+ console.log("[MES] - beforeSaveHook: Found " + runningOrders.length + " running orders with same tag.");
141
145
  if (runningOrders.length > 0 && object.get("status") === "running") {
142
146
  for (const runningOrder of runningOrders) {
143
147
  runningOrder.set("duration", Date.now() - runningOrder.get("start").getTime());
@@ -183,7 +187,6 @@ async function init() {
183
187
  runningData.name = "Order_Running";
184
188
  console.log("-".repeat(20));
185
189
  console.log("Publishing running order " + object.id);
186
- console.log("Data:", runningData);
187
190
  console.log("-".repeat(20));
188
191
  await (0, index_js_1.publishDataItem)(runningData, user?.getEmail() || undefined, true);
189
192
  }
@@ -305,7 +308,6 @@ async function createValueArrayForObject(object, extraValues, fields) {
305
308
  }
306
309
  values.push(value);
307
310
  }
308
- console.log("[MES] - createValueArrayForObject: Created values object for order " + object.id + ": ", values);
309
311
  return [{ date: object.get("start").getTime(), value: values }];
310
312
  }
311
313
  function scheduleOrderStartedStatusCheck(cronInterval) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "4.0.26",
3
+ "version": "4.0.28",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@10.33.0",
6
6
  "keywords": [