@7365admin1/module-hygiene 4.27.1 → 4.27.2-staging.4
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/.github/workflows/publish-staging.yml +36 -0
- package/dist/index.js +26 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3284,7 +3284,19 @@ function useAreaChecklistRepo() {
|
|
|
3284
3284
|
}
|
|
3285
3285
|
async function createUniqueIndex() {
|
|
3286
3286
|
try {
|
|
3287
|
-
await collection.createIndex(
|
|
3287
|
+
await collection.createIndex(
|
|
3288
|
+
{ schedule: 1, area: 1, serviceType: 1 },
|
|
3289
|
+
{ unique: true }
|
|
3290
|
+
);
|
|
3291
|
+
const legacyIndex = (await collection.indexes()).find((index) => {
|
|
3292
|
+
return index.unique === true && JSON.stringify(index.key) === JSON.stringify({ schedule: 1, area: 1 });
|
|
3293
|
+
});
|
|
3294
|
+
if (legacyIndex?.name) {
|
|
3295
|
+
await collection.dropIndex(legacyIndex.name);
|
|
3296
|
+
logger17.info(
|
|
3297
|
+
`Dropped legacy hygiene area checklist unique index: ${legacyIndex.name}`
|
|
3298
|
+
);
|
|
3299
|
+
}
|
|
3288
3300
|
} catch (error) {
|
|
3289
3301
|
throw new InternalServerError5(
|
|
3290
3302
|
"Failed to create unique index on hygiene checklist area."
|
|
@@ -3296,7 +3308,7 @@ function useAreaChecklistRepo() {
|
|
|
3296
3308
|
const parentChecklistId = new ObjectId9(value.schedule);
|
|
3297
3309
|
const areaId = new ObjectId9(value.area);
|
|
3298
3310
|
const existingChecklist = await collection.findOne(
|
|
3299
|
-
{ schedule: parentChecklistId, area: areaId },
|
|
3311
|
+
{ schedule: parentChecklistId, area: areaId, serviceType: value.serviceType },
|
|
3300
3312
|
{ session }
|
|
3301
3313
|
);
|
|
3302
3314
|
if (existingChecklist) {
|
|
@@ -3314,7 +3326,8 @@ function useAreaChecklistRepo() {
|
|
|
3314
3326
|
logger17.info(`Duplicate area checklist skipped for area ${value.name}`);
|
|
3315
3327
|
const existing = await collection.findOne({
|
|
3316
3328
|
schedule: new ObjectId9(value.schedule),
|
|
3317
|
-
area: new ObjectId9(value.area)
|
|
3329
|
+
area: new ObjectId9(value.area),
|
|
3330
|
+
serviceType: value.serviceType
|
|
3318
3331
|
});
|
|
3319
3332
|
return existing._id;
|
|
3320
3333
|
}
|
|
@@ -5163,9 +5176,18 @@ function useSupplyRepository() {
|
|
|
5163
5176
|
async function createUniqueIndex() {
|
|
5164
5177
|
try {
|
|
5165
5178
|
await collection.createIndex(
|
|
5166
|
-
{ site: 1, name: 1, deletedAt: 1 },
|
|
5179
|
+
{ site: 1, serviceType: 1, name: 1, deletedAt: 1 },
|
|
5167
5180
|
{ unique: true }
|
|
5168
5181
|
);
|
|
5182
|
+
const legacyIndex = (await collection.indexes()).find((index) => {
|
|
5183
|
+
return index.unique === true && JSON.stringify(index.key) === JSON.stringify({ site: 1, name: 1, deletedAt: 1 });
|
|
5184
|
+
});
|
|
5185
|
+
if (legacyIndex?.name) {
|
|
5186
|
+
await collection.dropIndex(legacyIndex.name);
|
|
5187
|
+
logger22.info(
|
|
5188
|
+
`Dropped legacy hygiene supply unique index: ${legacyIndex.name}`
|
|
5189
|
+
);
|
|
5190
|
+
}
|
|
5169
5191
|
} catch (error) {
|
|
5170
5192
|
throw new InternalServerError8(
|
|
5171
5193
|
"Failed to create unique index on hygiene supply."
|