tango-app-api-trax 3.6.0-sec-5 → 3.6.0-sec-7

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-trax",
3
- "version": "3.6.0-sec-5",
3
+ "version": "3.6.0-sec-7",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -18,11 +18,6 @@ import mongoose from 'mongoose';
18
18
  export const downloadInsert = async ( req, res ) => {
19
19
  try {
20
20
  let requestData = req.body;
21
- let fromDate = new Date( requestData.fromDate );
22
- let toDate = new Date( requestData.toDate );
23
- let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
24
- toDate = new Date( toDate.getTime() - userTimezoneOffset );
25
- toDate.setUTCHours( 23, 59, 59, 59 );
26
21
  let name;
27
22
  let fileType = requestData?.fileType || 'pdfzip';
28
23
 
@@ -44,55 +39,60 @@ export const downloadInsert = async ( req, res ) => {
44
39
  }
45
40
  }
46
41
  // console.log( requestData );
47
-
48
- if ( requestData.sourceCheckList_id && requestData.sourceCheckList_id != '' ) {
49
- let getChecklistQuery = [];
50
- getChecklistQuery.push( { $project: { sourceCheckList_id: 1, date_iso: 1, store_id: 1, userEmail: 1, checklistStatus: 1, redoStatus: 1 } } );
51
-
52
- if ( requestData.filtertype ==='Clusters' ) {
53
- getChecklistQuery.push( {
54
- $match: {
55
- $and: [
56
- { sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ) },
57
- { date_iso: { $gte: fromDate, $lte: toDate } },
58
- { store_id: { $in: requestData.storeIds } },
59
- ],
60
- $or: [
61
- { checklistStatus: 'submit' },
62
- { redoStatus: true },
63
- ],
64
- },
65
- } );
66
- } else {
67
- // console.log( requestData );
68
- getChecklistQuery.push( {
69
- $match: {
70
- $and: [
71
- { sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ) },
72
- { date_iso: { $gte: fromDate, $lte: toDate } },
73
- { userEmail: { $in: requestData.userEmailList } },
74
- ],
75
- $or: [
76
- { checklistStatus: 'submit' },
77
- { redoStatus: true },
78
- ],
79
- },
80
- } );
81
- }
82
- // getChecklistQuery.push( { $count: 'totalCount' } );
83
-
84
- let getChecklistCount = await processedchecklistService.aggregate( getChecklistQuery );
85
- // console.log( getChecklistCount );
86
- if ( requestData.insertType === 'task' ) {
87
- getChecklistCount = await processedTaskService.aggregate( getChecklistQuery );
88
- }
89
- if ( getChecklistCount && getChecklistCount.length > 0 ) {
90
- // console.log( 'if' );
91
- // console.log( 'getChecklistCountgetChecklistCount[0].totalCount =>', getChecklistCount[0]?.totalCount );
92
- } else {
93
- return res.sendError( { error: 'No Data Found' }, 400 );
94
- }
95
- }
42
+ // // No Need to Check
43
+ // let fromDate = new Date( requestData.fromDate );
44
+ // let toDate = new Date( requestData.toDate );
45
+ // let userTimezoneOffset = toDate.getTimezoneOffset() * 60000;
46
+ // toDate = new Date( toDate.getTime() - userTimezoneOffset );
47
+ // toDate.setUTCHours( 23, 59, 59, 59 );
48
+ // if ( requestData.sourceCheckList_id && requestData.sourceCheckList_id != '' ) {
49
+ // let getChecklistQuery = [];
50
+ // getChecklistQuery.push( { $project: { sourceCheckList_id: 1, date_iso: 1, store_id: 1, userEmail: 1, checklistStatus: 1, redoStatus: 1 } } );
51
+
52
+ // if ( requestData.filtertype ==='Clusters' ) {
53
+ // getChecklistQuery.push( {
54
+ // $match: {
55
+ // $and: [
56
+ // { sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ) },
57
+ // { date_iso: { $gte: fromDate, $lte: toDate } },
58
+ // { store_id: { $in: requestData.storeIds } },
59
+ // ],
60
+ // $or: [
61
+ // { checklistStatus: 'submit' },
62
+ // { redoStatus: true },
63
+ // ],
64
+ // },
65
+ // } );
66
+ // } else {
67
+ // // console.log( requestData );
68
+ // getChecklistQuery.push( {
69
+ // $match: {
70
+ // $and: [
71
+ // { sourceCheckList_id: new mongoose.Types.ObjectId( requestData.sourceCheckList_id ) },
72
+ // { date_iso: { $gte: fromDate, $lte: toDate } },
73
+ // { userEmail: { $in: requestData.userEmailList } },
74
+ // ],
75
+ // $or: [
76
+ // { checklistStatus: 'submit' },
77
+ // { redoStatus: true },
78
+ // ],
79
+ // },
80
+ // } );
81
+ // }
82
+ // // getChecklistQuery.push( { $count: 'totalCount' } );
83
+
84
+ // let getChecklistCount = await processedchecklistService.aggregate( getChecklistQuery );
85
+ // // console.log( getChecklistCount );
86
+ // if ( requestData.insertType === 'task' ) {
87
+ // getChecklistCount = await processedTaskService.aggregate( getChecklistQuery );
88
+ // }
89
+ // if ( getChecklistCount && getChecklistCount.length > 0 ) {
90
+ // // console.log( 'if' );
91
+ // // console.log( 'getChecklistCountgetChecklistCount[0].totalCount =>', getChecklistCount[0]?.totalCount );
92
+ // } else {
93
+ // return res.sendError( { error: 'No Data Found' }, 400 );
94
+ // }
95
+ // }
96
96
 
97
97
  if ( requestData.fileType == 'pdf' ) {
98
98
  if ( requestData?.sourceCheckList_id && requestData?.sourceCheckList_id != '' ) {
@@ -151,8 +151,8 @@ export async function startChecklist( req, res ) {
151
151
 
152
152
  let updateData = {};
153
153
  let currentDateTime;
154
- if ( getBeforeChecklist[0].storeName && getBeforeChecklist[0].storeName!='' ) {
155
- let storeTimeZone = await storeService.findOne( { storeName: { $regex: getBeforeChecklist[0].storeName, $options: 'i' }, clientId: getBeforeChecklist[0].client_id }, { 'storeProfile.timeZone': 1 } );
154
+ if ( getBeforeChecklist[0]?.store_id && getBeforeChecklist[0]?.store_id != '' ) {
155
+ let storeTimeZone = await storeService.findOne( { storeId: getBeforeChecklist[0].store_id, clientId: getBeforeChecklist[0].client_id }, { 'storeProfile.timeZone': 1 } );
156
156
  if ( storeTimeZone?.storeProfile?.timeZone ) {
157
157
  currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
158
158
  } else {
@@ -1803,8 +1803,8 @@ export async function submitChecklist( req, res ) {
1803
1803
 
1804
1804
  let currentDateTime;
1805
1805
  let storeTimeZone;
1806
- if ( getchecklist[0].storeName && getchecklist[0].storeName !='' ) {
1807
- storeTimeZone = await storeService.findOne( { storeName: { $regex: getchecklist[0].storeName, $options: 'i' }, clientId: getchecklist[0].client_id }, { 'storeProfile.timeZone': 1 } );
1806
+ if ( getchecklist[0]?.store_id && getchecklist[0]?.store_id !='' ) {
1807
+ storeTimeZone = await storeService.findOne( { storeId: getchecklist[0].store_id, clientId: getchecklist[0].client_id }, { 'storeProfile.timeZone': 1 } );
1808
1808
  if ( storeTimeZone?.storeProfile?.timeZone ) {
1809
1809
  currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
1810
1810
  } else {