tango-app-api-infra 3.8.2 → 3.8.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/README.md CHANGED
@@ -1,29 +1,29 @@
1
- # README #
2
-
3
- This README would normally document whatever steps are necessary to get your application up and running.
4
-
5
- ### What is this repository for? ###
6
-
7
- * Quick summary
8
- * Version
9
- * [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
10
-
11
- ### How do I get set up? ###
12
-
13
- * Summary of set up
14
- * Configuration
15
- * Dependencies
16
- * Database configuration
17
- * How to run tests
18
- * Deployment instructions
19
-
20
- ### Contribution guidelines ###
21
-
22
- * Writing tests
23
- * Code review
24
- * Other guidelines
25
-
26
- ### Who do I talk to? ###
27
-
28
- * Repo owner or admin
1
+ # README #
2
+
3
+ This README would normally document whatever steps are necessary to get your application up and running.
4
+
5
+ ### What is this repository for? ###
6
+
7
+ * Quick summary
8
+ * Version
9
+ * [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
10
+
11
+ ### How do I get set up? ###
12
+
13
+ * Summary of set up
14
+ * Configuration
15
+ * Dependencies
16
+ * Database configuration
17
+ * How to run tests
18
+ * Deployment instructions
19
+
20
+ ### Contribution guidelines ###
21
+
22
+ * Writing tests
23
+ * Code review
24
+ * Other guidelines
25
+
26
+ ### Who do I talk to? ###
27
+
28
+ * Repo owner or admin
29
29
  * Other community or team contact
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-infra",
3
- "version": "3.8.2",
3
+ "version": "3.8.4",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -22,9 +22,11 @@ export async function createTicket( req, res ) {
22
22
  inputData.duplicateACCount = 0;
23
23
  inputData.employeeACCount = 0;
24
24
  inputData.houseKeepingACCount = 0;
25
- inputData.houseKeepingCount = inputData.houseKeepingCount || 0;
26
- inputData.duplicateCount = inputData.duplicateCount || 0;
27
- inputData.employeeCount = inputData.employeeCount || 0;
25
+ inputData.junkACCount = 0;
26
+ inputData.houseKeepingCount = inputData?.houseKeepingCount || 0;
27
+ inputData.duplicateCount = inputData?.duplicateCount || 0;
28
+ inputData.employeeCount = inputData?.employeeCount || 0;
29
+ inputData.junkCount = inputData?.junkCount || 0;
28
30
  if ( inputData.houseKeepingCount > 0 ) {
29
31
  inputData.houseKeepingStatus = 'pending';
30
32
  }
@@ -34,6 +36,9 @@ export async function createTicket( req, res ) {
34
36
  if ( inputData.duplicateCount > 0 ) {
35
37
  inputData.duplicateStatus = 'pending';
36
38
  }
39
+ if ( inputData.junkCount > 0 ) {
40
+ inputData.junkStatus = 'pending';
41
+ }
37
42
  const id = `${inputData.storeId}_${inputData.dateString}_footfall-directory-tagging`;
38
43
  await insertWithId( openSearch.footfallDirectory, id, inputData );
39
44
  // update the status of each tempId to the revop-tagging index
@@ -74,7 +79,18 @@ async function bulkUpdateStatusToPending( indexName, inputData ) {
74
79
  }
75
80
  }
76
81
 
77
- // 3. Duplicate Images > data[]
82
+ // 3. junk
83
+ if ( inputData.junkCount > 0 ) {
84
+ for ( const emp of inputData.junk || [] ) {
85
+ const id = `${inputData.storeId}_${inputData.dateString}_${emp.timeRange}_${emp.tempId}`;
86
+ bulkBody.push(
87
+ { update: { _index: indexName, _id: id } },
88
+ { doc: { status: 'pending' } },
89
+ );
90
+ }
91
+ }
92
+
93
+ // 4. Duplicate Images > data[]
78
94
  if ( inputData.duplicateCount > 0 ) {
79
95
  for ( const dup of inputData.duplicateImages || [] ) {
80
96
  let updatedDuplicateImages = [];
@@ -163,6 +179,11 @@ export async function ticketSummary( req, res ) {
163
179
  field: 'houseKeepingCount',
164
180
  },
165
181
  },
182
+ junkCount: {
183
+ sum: {
184
+ field: 'junkCount',
185
+ },
186
+ },
166
187
  },
167
188
  };
168
189
 
@@ -177,7 +198,8 @@ export async function ticketSummary( req, res ) {
177
198
  duplicateCount: aggs.duplicateCount.value,
178
199
  employeeCount: aggs.employeeCount.value,
179
200
  houseKeepingCount: aggs.houseKeepingCount.value,
180
- noShopper: aggs.duplicateCount.value + aggs.employeeCount.value + aggs.houseKeepingCount.value,
201
+ junkCount: aggs.junkCount.value,
202
+ noShopper: aggs.duplicateCount.value + aggs.employeeCount.value + aggs.houseKeepingCount.value + aggs.junkCount.value,
181
203
  };
182
204
 
183
205
  return res.sendSuccess( { result: result } );
@@ -283,9 +305,11 @@ export async function ticketList( req, res ) {
283
305
  'duplicateCount',
284
306
  'employeeCount',
285
307
  'houseKeepingCount',
308
+ 'junkCount',
286
309
  'employeeACCount',
287
310
  'duplicateACCount',
288
311
  'houseKeepingACCount',
312
+ 'junkACCount',
289
313
  'status',
290
314
  'dateString',
291
315
  ],
@@ -320,10 +344,12 @@ export async function ticketList( req, res ) {
320
344
  'duplicateCount',
321
345
  'employeeCount',
322
346
  'houseKeepingCount',
347
+ 'junkCount',
323
348
  'status',
324
349
  'employeeACCount',
325
350
  'duplicateACCount',
326
351
  'houseKeepingACCount',
352
+ 'junkACCount',
327
353
  'dateString',
328
354
  ],
329
355
  'from': offset,
@@ -352,6 +378,8 @@ export async function ticketList( req, res ) {
352
378
  'employeeCount',
353
379
  'houseKeepingACCount',
354
380
  'houseKeepingCount',
381
+ 'junkCount',
382
+ 'junkACCount',
355
383
  'status',
356
384
  'dateString',
357
385
  ],
@@ -387,8 +415,9 @@ export async function ticketList( req, res ) {
387
415
  'Duplicates': item?._source?.status === 'closed'? item._source.duplicateACCount : item._source.duplicateCount,
388
416
  'Employee/Staff': item?._source?.status === 'closed'? item._source.employeeACCount : item._source.employeeCount,
389
417
  'HouseKeeping': item?._source?.status === 'closed'? item._source.houseKeepingACCount : item._source.houseKeepingCount,
390
- 'Revised Footfall': item?._source?.status === 'closed'? item._source.footfallCount - ( item._source.duplicateACCount + item._source.employeeACCount + item._source.houseKeepingACCount ) : item._source.footfallCount - ( item._source.duplicateCount + item._source.employeeCount + item._source.houseKeepingCount ),
391
- 'Ticket%': item?._source?.status === 'closed'?`${Math.round( ( ( item._source.duplicateACCount + item._source.employeeACCount + item._source.houseKeepingACCount )/ item._source.footfallCount )*100 ).toFixed( 0 )} %` : `${Math.round( ( ( item?._source?.duplicateCount + item?._source?.employeeCount + item?._source?.houseKeepingCount )/ item?._source?.footfallCount )*100 ).toFixed( 0 )} %`,
418
+ 'Junk': item?._source?.status === 'closed'? item._source.junkACCount : item._source.junkCount,
419
+ 'Revised Footfall': item?._source?.status === 'closed'? item._source.footfallCount - ( item._source.duplicateACCount + item._source.employeeACCount + item._source.houseKeepingACCount + item._source.junkACCount ) : item._source.footfallCount - ( item._source.duplicateCount + item._source.employeeCount + item._source.houseKeepingCount + item._source.junkCount ),
420
+ 'Ticket%': item?._source?.status === 'closed'?`${Math.round( ( ( item._source.duplicateACCount + item._source.employeeACCount + item._source.houseKeepingACCount + item._source.junkACCount )/ item._source.footfallCount )*100 ).toFixed( 0 )} %` : `${Math.round( ( ( item?._source?.duplicateCount + item?._source?.employeeCount + item?._source?.houseKeepingCount + item._source.junkCount )/ item?._source?.footfallCount )*100 ).toFixed( 0 )} %`,
392
421
  'Status': item._source.status,
393
422
  } );
394
423
  }
@@ -410,7 +439,7 @@ export async function getTickets( req, res ) {
410
439
  const skip = inputData.offset == 0 ? 0 : ( inputData.offset - 1 ) * limit || 0;
411
440
  inputData.storeId = inputData.storeId.split( ',' ); // convert strig to array
412
441
  logger.info( { inputData: inputData, limit: limit, skip: skip } );
413
- let source = [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'employeeCount', 'houseKeepingCount', 'duplicateCount', 'comments', 'employee', 'houseKeeping', 'duplicateImages', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'email', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus', 'houseKeepingACCount', 'houseKeepingCount', 'employeeCount', 'employeeACCount', 'duplicateCount', 'duplicateACCount', 'approverRole', 'approverUserName', 'approverEmail' ];
442
+ let source = [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'employeeCount', 'houseKeepingCount', 'duplicateCount', 'junkCount', 'junkACCount', 'comments', 'employee', 'houseKeeping', 'junk', 'duplicateImages', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'email', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus', 'houseKeepingACCount', 'houseKeepingCount', 'employeeCount', 'employeeACCount', 'duplicateCount', 'duplicateACCount', 'approverRole', 'approverUserName', 'approverEmail' ];
414
443
  let filter = [
415
444
 
416
445
  {
@@ -470,6 +499,14 @@ export async function getTickets( req, res ) {
470
499
  gt: 0,
471
500
  },
472
501
  },
502
+ } ) :
503
+ inputData.revopsType === 'junk' ?
504
+ filter.push( {
505
+ range: {
506
+ junkCount: {
507
+ gt: 0,
508
+ },
509
+ },
473
510
  } ) :
474
511
  filter.push( {
475
512
  range: {
@@ -478,9 +515,10 @@ export async function getTickets( req, res ) {
478
515
  },
479
516
  },
480
517
  } );
481
- source = inputData.revopsType == 'employee' ? [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'employeeCount', 'comments', 'employee', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'email', 'userName', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus', 'houseKeepingACCount', 'houseKeepingCount', 'employeeCount', 'employeeACCount', 'duplicateCoun', 'duplicateACCount', 'approverRole', 'approverUserName', 'approverEmail' ] :
482
- inputData.revopsType == 'houseKeeping' ? [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'houseKeepingCount', 'comments', 'houseKeeping', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'email', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus', 'houseKeepingACCount', 'houseKeepingCount', 'employeeCount', 'employeeACCount', 'duplicateCount', 'duplicateACCount', 'approverRole', 'approverUserName', 'approverEmail' ] :
483
- inputData.revopsType == 'duplicateImages' ? [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'duplicateCount', 'comments', 'duplicateImages', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'email', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus', 'houseKeepingACCount', 'houseKeepingCount', 'employeeCount', 'employeeACCount', 'duplicateCount', 'duplicateACCount', 'approverRole', 'approverUserName', 'approverEmail' ] : [];
518
+ source = inputData.revopsType == 'employee' ? [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'employeeCount', 'comments', 'employee', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'email', 'userName', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus', 'houseKeepingACCount', 'houseKeepingCount', 'employeeCount', 'employeeACCount', 'duplicateCount', 'duplicateACCount', 'junkCount', 'junkStatus', 'junkACCount', 'approverRole', 'approverUserName', 'approverEmail' ] :
519
+ inputData.revopsType == 'houseKeeping' ? [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'houseKeepingCount', 'comments', 'houseKeeping', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'email', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus', 'houseKeepingACCount', 'houseKeepingCount', 'employeeCount', 'employeeACCount', 'duplicateCount', 'duplicateACCount', 'junkCount', 'junkStatus', 'junkACCount', 'approverRole', 'approverUserName', 'approverEmail' ] :
520
+ inputData.revopsType == 'duplicateImages' ? [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'duplicateCount', 'comments', 'duplicateImages', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'email', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus', 'houseKeepingACCount', 'houseKeepingCount', 'employeeCount', 'employeeACCount', 'duplicateCount', 'duplicateACCount', 'junkCount', 'junkStatus', 'junkACCount', 'approverRole', 'approverUserName', 'approverEmail' ] :
521
+ inputData.revopsType == 'junk' ? [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'duplicateCount', 'comments', 'junk', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'email', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus', 'houseKeepingACCount', 'houseKeepingCount', 'employeeCount', 'employeeACCount', 'duplicateCount', 'duplicateACCount', 'junkCount', 'junkACCount', 'junkStatus', 'approverRole', 'approverUserName', 'approverEmail' ] : [];
484
522
  }
485
523
 
486
524
  if ( inputData.action ) {
@@ -508,6 +546,13 @@ export async function getTickets( req, res ) {
508
546
  _name: 'matched_duplicate',
509
547
  },
510
548
  },
549
+ {
550
+ constant_score: {
551
+ filter: { term: { 'junkStatus.keyword': inputData.action } },
552
+ boost: 1,
553
+ _name: 'matched_junk',
554
+ },
555
+ },
511
556
  ],
512
557
  minimum_should_match: 1,
513
558
  },
@@ -527,7 +572,7 @@ export async function getTickets( req, res ) {
527
572
  aggs: {
528
573
  totalCount: {
529
574
  sum: {
530
- field: inputData.revopsType == 'employee' ? 'employeeCount' : inputData.revopsType == 'houseKeeping' ? 'houseKeepingCount' : 'duplicateCount',
575
+ field: inputData.revopsType == 'employee' ? 'employeeCount' : inputData.revopsType == 'houseKeeping' ? 'houseKeepingCount' :inputData.revopsType == 'junk' ? 'junkCount': 'duplicateCount',
531
576
  },
532
577
  },
533
578
  },
@@ -586,6 +631,7 @@ export async function getTickets( req, res ) {
586
631
  employeeStatus: hit?._source?.employeeStatus,
587
632
  houseKeepingStatus: hit?._source?.houseKeepingStatus,
588
633
  duplicateStatus: hit?._source?.duplicateStatus,
634
+ junkStatus: hit?._source?.junkStatus,
589
635
  storeName: hit?._source?.storeName,
590
636
  ticketId: hit?._source?.ticketId,
591
637
  footfallCount: hit?._source?.footfallCount,
@@ -599,14 +645,14 @@ export async function getTickets( req, res ) {
599
645
  houseKeepingCount: hit?._source?.houseKeepingCount,
600
646
  employeeCount: hit?._source?.employeeCount,
601
647
  duplicateCount: hit?._source?.duplicateCount,
648
+ junkCount: hit?._source?.junkCount,
602
649
  houseKeepingACCount: hit?._source?.houseKeepingACCount,
603
650
  employeeACCount: hit?._source?.employeeACCount,
604
651
  duplicateACCount: hit?._source?.duplicateACCount,
652
+ junkACCount: hit?._source?.junkACCount,
605
653
  approverUserName: hit?._source?.approverUserName,
606
654
  approverEmail: hit?._source?.approverEmail,
607
655
  approverRole: hit?._source?.approverRole,
608
-
609
-
610
656
  };
611
657
  let result;
612
658
 
@@ -621,13 +667,17 @@ export async function getTickets( req, res ) {
621
667
  if ( matched.includes( 'matched_housekeeping' )&& ( !inputData.revopsType || inputData.revopsType == 'houseKeeping' ) ) {
622
668
  result = defaultData;
623
669
  result.houseKeeping = hit?._source?.houseKeeping;
624
- // result.type = 'houseKeeping';
625
670
  result.matched = matched;
626
671
  }
627
672
  if ( matched.includes( 'matched_duplicate' )&& ( !inputData.revopsType || inputData.revopsType == 'duplicateImages' ) ) {
628
673
  result = defaultData;
629
674
  result.duplicateImages = hit?._source?.duplicateImages;
630
- // result.type = 'duplicateImages';
675
+ result.matched = matched;
676
+ }
677
+
678
+ if ( matched.includes( 'matched_junk' )&& ( !inputData.revopsType || inputData.revopsType == 'junk' ) ) {
679
+ result = defaultData;
680
+ result.junk = hit?._source?.junk;
631
681
  result.matched = matched;
632
682
  }
633
683
 
@@ -817,6 +867,15 @@ async function extractCheckedTempIds( document ) {
817
867
  }
818
868
  }
819
869
 
870
+ // junk
871
+ if ( source.junkACCount > 0 && Array.isArray( source.junk ) ) {
872
+ for ( const hk of source.junk ) {
873
+ if ( hk.isChecked === true ) {
874
+ result.push( { tempId: hk.tempId, timeRange: hk.timeRange } );
875
+ }
876
+ }
877
+ }
878
+
820
879
  // Duplicate Images
821
880
  if ( source.duplicateACCount > 0 && Array.isArray( source.duplicateImages ) ) {
822
881
  for ( const image of source.duplicateImages ) {
@@ -1018,7 +1077,8 @@ export async function getTaggedStores( req, res ) {
1018
1077
  source: `
1019
1078
  return (doc.containsKey('duplicateCount') ? doc['duplicateCount'].value : 0)
1020
1079
  + (doc.containsKey('houseKeepingCount') ? doc['houseKeepingCount'].value : 0)
1021
- + (doc.containsKey('employeeCount') ? doc['employeeCount'].value : 0);
1080
+ + (doc.containsKey('employeeCount') ? doc['employeeCount'].value : 0)
1081
+ + (doc.containsKey('junkCount') ? doc['junkCount'].value : 0);
1022
1082
  `,
1023
1083
  lang: 'painless',
1024
1084
  },
@@ -1066,7 +1126,7 @@ export async function downloadTickets( req, res ) {
1066
1126
  const inputData = req.query;
1067
1127
  const limit = inputData.limit;
1068
1128
  const skip = inputData.offset == 0 ? 0 : ( inputData.offset - 1 ) * limit || 0;
1069
- let source = [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'employeeCount', 'houseKeepingCount', 'duplicateCount', 'comments', 'employee', 'houseKeeping', 'duplicateImages', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus' ];
1129
+ let source = [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'employeeCount', 'houseKeepingCount', 'duplicateCount', 'junkCount', 'comments', 'employee', 'junk', 'houseKeeping', 'duplicateImages', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus', 'junkStatus' ];
1070
1130
  let filter = [
1071
1131
 
1072
1132
  {
@@ -1131,7 +1191,17 @@ export async function downloadTickets( req, res ) {
1131
1191
  gt: 0,
1132
1192
  },
1133
1193
  },
1194
+
1134
1195
  } ) :
1196
+ inputData.revopsType === 'junk' ?
1197
+ filter.push( {
1198
+ range: {
1199
+ junkCount: {
1200
+ gt: 0,
1201
+ },
1202
+ },
1203
+ } ):
1204
+
1135
1205
  filter.push( {
1136
1206
  range: {
1137
1207
  duplicateCount: {
@@ -1139,9 +1209,10 @@ export async function downloadTickets( req, res ) {
1139
1209
  },
1140
1210
  },
1141
1211
  } );
1142
- source = inputData.revopsType == 'employee' ? [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'employeeCount', 'comments', 'employee', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus' ] :
1143
- inputData.revopsType == 'houseKeeping' ? [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'houseKeepingCount', 'comments', 'houseKeeping', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus' ] :
1144
- inputData.revopsType == 'duplicateImages' ? [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'duplicateCount', 'comments', 'duplicateImages', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus' ] : [];
1212
+ source = inputData.revopsType == 'employee' ? [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'employeeCount', 'comments', 'employee', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus', 'junkStatus' ] :
1213
+ inputData.revopsType == 'houseKeeping' ? [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'houseKeepingCount', 'comments', 'houseKeeping', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus', 'junkStatus' ] :
1214
+ inputData.revopsType == 'duplicateImages' ? [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'duplicateCount', 'comments', 'duplicateImages', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus', 'junkStatus' ] :
1215
+ inputData.revopsType == 'junk' ? [ 'storeId', 'dateString', 'ticketName', 'footfallCount', 'junkCount', 'comments', 'junk', 'ticketId', 'clientId', 'storeName', 'createdAt', 'updatedAt', 'userName', 'role', 'status', 'employeeStatus', 'houseKeepingStatus', 'duplicateStatus', 'junkStatus' ] : [];
1145
1216
  }
1146
1217
 
1147
1218
  if ( inputData.action ) {
@@ -1169,6 +1240,13 @@ export async function downloadTickets( req, res ) {
1169
1240
  _name: 'matched_duplicate',
1170
1241
  },
1171
1242
  },
1243
+ {
1244
+ constant_score: {
1245
+ filter: { term: { 'junkStatus.keyword': inputData.action } },
1246
+ boost: 1,
1247
+ _name: 'matched_junk',
1248
+ },
1249
+ },
1172
1250
  ],
1173
1251
  minimum_should_match: 1,
1174
1252
  },
@@ -1216,6 +1294,7 @@ export async function downloadTickets( req, res ) {
1216
1294
  dateString: hit?._source?.dateString,
1217
1295
  ticketName: hit?._source?.ticketName,
1218
1296
  status: hit?._source?.status,
1297
+ junkStatus: hit?._source?.junkStatus,
1219
1298
  employeeStatus: hit?._source?.employeeStatus,
1220
1299
  houseKeepingStatus: hit?._source?.houseKeepingStatus,
1221
1300
  duplicateStatus: hit?._source?.duplicateStatus,
@@ -1244,18 +1323,20 @@ export async function downloadTickets( req, res ) {
1244
1323
  logger.info( { revop: inputData.revopsType } );
1245
1324
  result = defaultData;
1246
1325
  result.houseKeeping = hit?._source?.houseKeeping;
1247
- // result.type = 'houseKeeping';
1248
1326
  result.matched = matched;
1249
1327
  }
1250
1328
  if ( matched.includes( 'matched_duplicate' )&& ( !inputData.revopsType || inputData.revopsType == 'duplicateImages' ) ) {
1251
1329
  logger.info( { revop: inputData.revopsType } );
1252
1330
  result = defaultData;
1253
1331
  result.duplicateImages = hit?._source?.duplicateImages;
1254
- // result.type = 'duplicateImages';
1332
+ result.matched = matched;
1333
+ }
1334
+ if ( matched.includes( 'matched_junk' )&& ( !inputData.revopsType || inputData.revopsType == 'junk' ) ) {
1335
+ result = defaultData;
1336
+ result.junk = hit?._source?.junk;
1255
1337
  result.matched = matched;
1256
1338
  }
1257
1339
  if ( result ) {
1258
- logger.info( { revop: inputData.revopsType, result: result } );
1259
1340
  const nested = [
1260
1341
  {
1261
1342
  _id: hit._id,
@@ -1359,6 +1440,13 @@ async function extractTempIds( document ) {
1359
1440
  }
1360
1441
  }
1361
1442
 
1443
+ // junk
1444
+ if ( Array.isArray( source.junk ) ) {
1445
+ for ( const hk of source.junk ) {
1446
+ result.push( hk.filePath );
1447
+ }
1448
+ }
1449
+
1362
1450
  // Duplicate Images
1363
1451
  if ( Array.isArray( source.duplicateImages ) ) {
1364
1452
  for ( const image of source.duplicateImages ) {
@@ -10,6 +10,7 @@ export const createTicketSchema = Joi.object().keys( {
10
10
  duplicateCount: Joi.number().optional(),
11
11
  employeeCount: Joi.number().optional(),
12
12
  houseKeepingCount: Joi.number().optional(),
13
+ junkCount: Joi.number().optional(),
13
14
  comments: Joi.string().optional().allow( '' ),
14
15
  duplicateImages: Joi.array().items(
15
16
  Joi.object( {
@@ -50,6 +51,16 @@ export const createTicketSchema = Joi.object().keys( {
50
51
 
51
52
  } ) ).optional(),
52
53
 
54
+ junk: Joi.array().items( Joi.object( {
55
+ tempId: Joi.number().required(),
56
+ filePath: Joi.string().required(),
57
+ entryTime: Joi.string().required(),
58
+ exitTime: Joi.string().required(),
59
+ timeRange: Joi.string().required(),
60
+ isChecked: Joi.boolean().required(),
61
+
62
+ } ) ).optional(),
63
+
53
64
 
54
65
  } );
55
66