tango-app-api-store-builder 1.0.12 → 1.0.13
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as floorService from '../service/storeBuilder.service.js';
|
|
2
|
-
import { logger, insertOpenSearchData, getOpenSearchData } from 'tango-app-api-middleware';
|
|
2
|
+
import { logger, insertOpenSearchData, getOpenSearchData, updateOpenSearchData, getOpenSearchById } from 'tango-app-api-middleware';
|
|
3
3
|
// import * as storeService from '../service/store.service.js';
|
|
4
4
|
import * as planoService from '../service/planogram.service.js';
|
|
5
5
|
import * as storeFixtureService from '../service/storeFixture.service.js';
|
|
@@ -1535,6 +1535,12 @@ export async function updateStoreFixture( req, res ) {
|
|
|
1535
1535
|
);
|
|
1536
1536
|
|
|
1537
1537
|
}
|
|
1538
|
+
|
|
1539
|
+
if ( data?.userAction === 'editWithAi' || data?.userAction === 'acceptAi' ) {
|
|
1540
|
+
const op_id = `${data?.storeName}_${data?.storeDate}_${data?._id}`
|
|
1541
|
+
await updateAIFeedbackInOpenSearch(data,op_id);
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1538
1544
|
// if ( req.body?.editMode ) {
|
|
1539
1545
|
// await floorService.updateOne( { _id: new mongoose.Types.ObjectId( currentFixture.floorId ) }, { isEdited: true } );
|
|
1540
1546
|
// }
|
|
@@ -1545,6 +1551,64 @@ export async function updateStoreFixture( req, res ) {
|
|
|
1545
1551
|
}
|
|
1546
1552
|
}
|
|
1547
1553
|
|
|
1554
|
+
const updateAIFeedbackInOpenSearch = async (fixtureData, id) => {
|
|
1555
|
+
|
|
1556
|
+
try {
|
|
1557
|
+
let openSearchDetails = await getOpenSearchById(JSON.parse(process.env.OPENSEARCH).planoAIValidation, id);
|
|
1558
|
+
if (openSearchDetails && openSearchDetails.statusCode == 200 && openSearchDetails?.body?._source) {
|
|
1559
|
+
|
|
1560
|
+
const doc = {
|
|
1561
|
+
"fixtureId": fixtureData._id,
|
|
1562
|
+
"fixtureCapacity": fixtureData.fixtureCapacity,
|
|
1563
|
+
"fixtureType": fixtureData.fixtureType,
|
|
1564
|
+
"fixtureCategory": fixtureData.fixtureCategory,
|
|
1565
|
+
"header": {
|
|
1566
|
+
"label": fixtureData.header.label,
|
|
1567
|
+
},
|
|
1568
|
+
"vmConfig": fixtureData?.vmConfig.map(vm => {
|
|
1569
|
+
return {
|
|
1570
|
+
"vmType": vm.vmType,
|
|
1571
|
+
"startYPosition": vm.startYPosition,
|
|
1572
|
+
"endYPosition": vm.endYPosition,
|
|
1573
|
+
"xZone": vm.xZone,
|
|
1574
|
+
"yZone": vm.yZone,
|
|
1575
|
+
"vmImage": vm.vmImage,
|
|
1576
|
+
"vmName": vm.vmName,
|
|
1577
|
+
}
|
|
1578
|
+
}) ?? [
|
|
1579
|
+
|
|
1580
|
+
],
|
|
1581
|
+
"shelfConfig": fixtureData?.shelfConfig.map(s => {
|
|
1582
|
+
return {
|
|
1583
|
+
"shelfNumber": s.shelfNumber,
|
|
1584
|
+
"shelfType": s.shelfType,
|
|
1585
|
+
"productPerShelf": s.productPerShelf,
|
|
1586
|
+
"trayRows": s.trayRows
|
|
1587
|
+
}
|
|
1588
|
+
}) ?? [],
|
|
1589
|
+
"fixtureImage": fixtureData.fixtureImage,
|
|
1590
|
+
"storeDate": fixtureData.storeDate
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
const document = {
|
|
1594
|
+
doc: doc,
|
|
1595
|
+
};
|
|
1596
|
+
|
|
1597
|
+
let updateResult = await updateOpenSearchData(JSON.parse(process.env.OPENSEARCH).planoAIValidation, id, document);
|
|
1598
|
+
|
|
1599
|
+
if (updateResult?.statusCode == 200) {
|
|
1600
|
+
return true;
|
|
1601
|
+
}
|
|
1602
|
+
return false
|
|
1603
|
+
} else {
|
|
1604
|
+
return false
|
|
1605
|
+
}
|
|
1606
|
+
} catch (e) {
|
|
1607
|
+
logger.error({ error: e, function: 'updateAIFeedbackInOpenSearch' });
|
|
1608
|
+
return false
|
|
1609
|
+
}
|
|
1610
|
+
};
|
|
1611
|
+
|
|
1548
1612
|
export async function updateredostatus( req, res ) {
|
|
1549
1613
|
try {
|
|
1550
1614
|
if ( req.body.type === 'layout' ) {
|