@7365admin1/module-hygiene 4.25.0 → 4.26.0
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 +6 -0
- package/dist/index.js +21 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -3265,6 +3265,14 @@ function useAreaChecklistRepo() {
|
|
|
3265
3265
|
const namespace_collection = "site.cleaning.schedule.areas";
|
|
3266
3266
|
const collection = db.collection(namespace_collection);
|
|
3267
3267
|
const { delNamespace, setCache, getCache } = (0, import_node_server_utils17.useCache)(namespace_collection);
|
|
3268
|
+
async function invalidateNamespaceCache(context) {
|
|
3269
|
+
try {
|
|
3270
|
+
await delNamespace();
|
|
3271
|
+
import_node_server_utils17.logger.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
3272
|
+
} catch (err) {
|
|
3273
|
+
import_node_server_utils17.logger.error(`Failed to clear cache for ${context}`, err);
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3268
3276
|
async function createIndex() {
|
|
3269
3277
|
try {
|
|
3270
3278
|
await collection.createIndexes([
|
|
@@ -3319,14 +3327,7 @@ function useAreaChecklistRepo() {
|
|
|
3319
3327
|
}
|
|
3320
3328
|
const processedValue = MAreaChecklist(value);
|
|
3321
3329
|
const result = await collection.insertOne(processedValue, { session });
|
|
3322
|
-
|
|
3323
|
-
import_node_server_utils17.logger.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
3324
|
-
}).catch((err) => {
|
|
3325
|
-
import_node_server_utils17.logger.error(
|
|
3326
|
-
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
3327
|
-
err
|
|
3328
|
-
);
|
|
3329
|
-
});
|
|
3330
|
+
await invalidateNamespaceCache("area checklist create");
|
|
3330
3331
|
return result.insertedId;
|
|
3331
3332
|
} catch (error) {
|
|
3332
3333
|
if (error?.code === 11e3) {
|
|
@@ -4063,14 +4064,7 @@ function useAreaChecklistRepo() {
|
|
|
4063
4064
|
if (res.modifiedCount === 0) {
|
|
4064
4065
|
throw new import_node_server_utils17.InternalServerError("Unable to update area checklist unit.");
|
|
4065
4066
|
}
|
|
4066
|
-
|
|
4067
|
-
import_node_server_utils17.logger.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
4068
|
-
}).catch((err) => {
|
|
4069
|
-
import_node_server_utils17.logger.error(
|
|
4070
|
-
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
4071
|
-
err
|
|
4072
|
-
);
|
|
4073
|
-
});
|
|
4067
|
+
await invalidateNamespaceCache("area checklist unit update");
|
|
4074
4068
|
return res.modifiedCount;
|
|
4075
4069
|
} catch (error) {
|
|
4076
4070
|
import_node_server_utils17.logger.error("Error updating area checklist unit:", error.message);
|
|
@@ -4096,14 +4090,7 @@ function useAreaChecklistRepo() {
|
|
|
4096
4090
|
if (res.modifiedCount === 0) {
|
|
4097
4091
|
throw new import_node_server_utils17.InternalServerError("Unable to update area checklist.");
|
|
4098
4092
|
}
|
|
4099
|
-
|
|
4100
|
-
import_node_server_utils17.logger.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
4101
|
-
}).catch((err) => {
|
|
4102
|
-
import_node_server_utils17.logger.error(
|
|
4103
|
-
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
4104
|
-
err
|
|
4105
|
-
);
|
|
4106
|
-
});
|
|
4093
|
+
await invalidateNamespaceCache("area checklist update");
|
|
4107
4094
|
return res.modifiedCount;
|
|
4108
4095
|
} catch (error) {
|
|
4109
4096
|
throw error;
|
|
@@ -4133,14 +4120,7 @@ function useAreaChecklistRepo() {
|
|
|
4133
4120
|
"Unable to update area checklist status."
|
|
4134
4121
|
);
|
|
4135
4122
|
}
|
|
4136
|
-
|
|
4137
|
-
import_node_server_utils17.logger.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
4138
|
-
}).catch((err) => {
|
|
4139
|
-
import_node_server_utils17.logger.error(
|
|
4140
|
-
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
4141
|
-
err
|
|
4142
|
-
);
|
|
4143
|
-
});
|
|
4123
|
+
await invalidateNamespaceCache("area checklist status update");
|
|
4144
4124
|
return res.modifiedCount;
|
|
4145
4125
|
} catch (error) {
|
|
4146
4126
|
throw error;
|
|
@@ -4553,16 +4533,14 @@ function useAreaChecklistService() {
|
|
|
4553
4533
|
if (allUnitsResult && allUnitsResult.items && allUnitsResult.items.length > 0) {
|
|
4554
4534
|
const sets = allUnitsResult.items;
|
|
4555
4535
|
const allUnits = sets.flatMap((set2) => set2.units || []);
|
|
4556
|
-
const openCount = allUnits.filter(
|
|
4557
|
-
(unit) => unit.status === "Open"
|
|
4558
|
-
).length;
|
|
4559
|
-
const completedCount = allUnits.filter(
|
|
4560
|
-
(unit) => unit.status === "Completed"
|
|
4561
|
-
).length;
|
|
4562
4536
|
const totalCount = allUnits.length;
|
|
4563
|
-
|
|
4537
|
+
const actionedCount = allUnits.filter((unit) => {
|
|
4538
|
+
const status = String(unit.status ?? "").toLowerCase();
|
|
4539
|
+
return unit.approve === true || unit.reject === true || status === "completed" || status === "closed";
|
|
4540
|
+
}).length;
|
|
4541
|
+
if (totalCount > 0 && actionedCount === totalCount) {
|
|
4564
4542
|
areaStatus = "completed";
|
|
4565
|
-
} else if (
|
|
4543
|
+
} else if (actionedCount === 0) {
|
|
4566
4544
|
areaStatus = "open";
|
|
4567
4545
|
} else {
|
|
4568
4546
|
areaStatus = "ongoing";
|
|
@@ -4581,11 +4559,12 @@ function useAreaChecklistService() {
|
|
|
4581
4559
|
);
|
|
4582
4560
|
if (allAreasResult && allAreasResult.items && allAreasResult.items.length > 0) {
|
|
4583
4561
|
const areas = allAreasResult.items;
|
|
4562
|
+
const normalizeStatus = (status) => String(status ?? "").toLowerCase();
|
|
4584
4563
|
const openAreasCount = areas.filter(
|
|
4585
|
-
(area) => area.status === "
|
|
4564
|
+
(area) => normalizeStatus(area.status) === "open"
|
|
4586
4565
|
).length;
|
|
4587
4566
|
const completedAreasCount = areas.filter(
|
|
4588
|
-
(area) => area.status === "
|
|
4567
|
+
(area) => normalizeStatus(area.status) === "completed"
|
|
4589
4568
|
).length;
|
|
4590
4569
|
const totalAreasCount = areas.length;
|
|
4591
4570
|
let parentStatus = "open";
|