tango-app-api-client 3.6.5-vms.15 → 3.6.5-vms.16

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,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-client",
3
- "version": "3.6.5-vms.15",
3
+ "version": "3.6.5-vms.16",
4
4
  "description": "client",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -112,10 +112,13 @@ export async function getAuditFile( req, res ) {
112
112
  address: '$storeProfile.address',
113
113
  };
114
114
  const storeDetails = await findOneStore( storeQuery, storeFields );
115
- let docId = `${inputData.storeId}_${inputData.Date}_internal_footfall-directory-tagging`;
115
+ let docId = `${inputData.storeId}_${inputData.Date}_footfall-directory-tagging`;
116
+ if ( inputData.tickettype === 'internal' ) {
117
+ docId = `${inputData.storeId}_${inputData.Date}_internal_footfall-directory-tagging`;
118
+ }
116
119
  console.log( '🚀 ~ getAuditFile ~ docId:draft', docId );
117
- const existingDoc = await getOpenSearchById( openSearch.footfallDirectory, docId );
118
- const ticketSource = existingDoc?.body?._source;
120
+ const existinginternalDoc = await getOpenSearchById( openSearch.footfallDirectory, docId );
121
+ let ticketSource = existinginternalDoc?.body?._source;
119
122
  const currentTime = new Date();
120
123
  const updatePayload = {
121
124
  doc: {
@@ -129,7 +132,24 @@ export async function getAuditFile( req, res ) {
129
132
  };
130
133
  console.log( '🚀 ~ getAuditFile ~ updatePayload:', updatePayload );
131
134
  console.log( '🚀 ~ getAuditFile ~ ticketSource:', ticketSource );
132
- if ( ticketSource ) {
135
+ if ( ticketSource && inputData.tickettype === 'store' ) {
136
+ ticketSource.mappingInfo.map( ( data ) => {
137
+ if ( data.type === 'tangoreview' ) {
138
+ data.status = 'In-Progress';
139
+ }
140
+ } );
141
+ ticketSource.createdByRole = req?.user?.role || '';
142
+ ticketSource.createdByEmail = req?.user?.email || '';
143
+ ticketSource.createdByUserName = req?.user?.userName || '';
144
+ ticketSource.createdByUserId = req?.user?._id || '';
145
+ console.log( '🚀 ~ getAuditFile ~ ticketSource:', ticketSource );
146
+ await updateOpenSearchData(
147
+ openSearch.footfallDirectory,
148
+ docId,
149
+ { doc: ticketSource },
150
+
151
+ );
152
+ } else if ( ticketSource && inputData.tickettype === 'internal' ) {
133
153
  await updateOpenSearchData(
134
154
  openSearch.footfallDirectory,
135
155
  docId,
@@ -184,10 +204,13 @@ export async function getAuditFile( req, res ) {
184
204
  console.log( openSearch.vmsAudit );
185
205
  let list = inputData.nextId ? await scrollResponse( inputData.nextId ) : await searchOpenSearchData( openSearch.vmsAudit, query );
186
206
 
187
- let docId = `${inputData.storeId}_${inputData.Date}_internal_footfall-directory-tagging`;
188
- console.log( '🚀 ~ getAuditFile ~ docId:1', docId );
189
- const existingDoc = await getOpenSearchById( openSearch.footfallDirectory, docId );
190
- const ticketSource = existingDoc?.body?._source;
207
+ let docId = `${inputData.storeId}_${inputData.Date}_footfall-directory-tagging`;
208
+ if ( inputData.tickettype === 'internal' ) {
209
+ docId = `${inputData.storeId}_${inputData.Date}_internal_footfall-directory-tagging`;
210
+ }
211
+ console.log( '🚀 ~ getAuditFile ~ docId:draft', docId );
212
+ const existinginternalDoc = await getOpenSearchById( openSearch.footfallDirectory, docId );
213
+ let ticketSource = existinginternalDoc?.body?._source;
191
214
  const currentTime = new Date();
192
215
  const updatePayload = {
193
216
  doc: {
@@ -201,7 +224,24 @@ export async function getAuditFile( req, res ) {
201
224
  };
202
225
  console.log( '🚀 ~ getAuditFile ~ updatePayload:', updatePayload );
203
226
  console.log( '🚀 ~ getAuditFile ~ ticketSource:', ticketSource );
204
- if ( ticketSource ) {
227
+ if ( ticketSource && inputData.tickettype != 'internal' ) {
228
+ ticketSource.mappingInfo.map( ( data ) => {
229
+ if ( data.type === 'tangoreview' ) {
230
+ data.status = 'In-Progress';
231
+ console.log( '🚀 ~ getAuditFile ~ data.status:', data.status );
232
+ }
233
+ } );
234
+ ticketSource.createdByRole = req?.user?.role || '';
235
+ ticketSource.createdByEmail = req?.user?.email || '';
236
+ ticketSource.createdByUserName = req?.user?.userName || '';
237
+ ticketSource.createdByUserId = req?.user?._id || '';
238
+ console.log( '🚀 ~ getAuditFile ~ ticketSource:', ticketSource );
239
+ await updateOpenSearchData(
240
+ openSearch.footfallDirectory,
241
+ docId,
242
+ { doc: ticketSource },
243
+ );
244
+ } else if ( ticketSource && inputData.tickettype === 'internal' ) {
205
245
  await updateOpenSearchData(
206
246
  openSearch.footfallDirectory,
207
247
  docId,
@@ -399,6 +439,9 @@ export async function reAssignAudit( req, res ) {
399
439
  const openSearch = JSON.parse( process.env.OPENSEARCH );
400
440
  let inputData = req.body;
401
441
  let docId = `${inputData.storeId}_${inputData.dateString}_internal_footfall-directory-tagging`;
442
+ if ( inputData.tickettype ==='store' ) {
443
+ docId = `${inputData.storeId}_${inputData.dateString}_footfall-directory-tagging`;
444
+ }
402
445
  console.log( '🚀 ~ getAuditFile ~ docId:draft', docId );
403
446
  const existingDoc = await getOpenSearchById( openSearch.footfallDirectory, docId );
404
447
  const ticketSource = existingDoc?.body?._source;
@@ -424,8 +467,9 @@ export async function reAssignAudit( req, res ) {
424
467
  );
425
468
  }
426
469
 
470
+ console.log( '🚀 ~ reAssignAudit ~ inputData.dateString:', inputData.dateString );
427
471
  await updatemanyvmsUserAudit(
428
- { auditStatus: { $ne: 'completed', storeId: inputData.storeId, fileDate: inputData.dateString } },
472
+ { auditStatus: { $ne: 'completed' }, storeId: inputData.storeId, fileDate: inputData.dateString },
429
473
  { status: 'skipped' } );
430
474
 
431
475
 
@@ -12,6 +12,7 @@ export const getFileSchema = joi.object( {
12
12
  storeId: joi.string().required(),
13
13
  Date: joi.string().required(),
14
14
  count: joi.string().required(),
15
+ tickettype: joi.string().required(),
15
16
  } );
16
17
 
17
18