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

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-6",
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 != '' ) {