tango-app-api-infra 3.0.16 → 3.0.18-dev
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 +5 -3
- package/src/controllers/clientInfra.controller.js +10 -1
- package/src/controllers/infra.controllers.js +44 -14
- package/src/controllers/storeInfra.controlller.js +41 -5
- package/src/controllers/userInfra.controller.js +195 -52
- package/src/routes/userInfra.routes.js +2 -1
- package/src/validations/infra.validation.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-infra",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.18-dev",
|
|
4
4
|
"description": "infra",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -14,14 +14,16 @@
|
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"aws-sdk": "^2.1571.0",
|
|
17
|
+
"cors": "^2.8.5",
|
|
17
18
|
"dayjs": "^1.11.10",
|
|
18
19
|
"dotenv": "^16.4.5",
|
|
19
20
|
"express": "^4.18.3",
|
|
21
|
+
"express-fileupload": "^1.5.0",
|
|
20
22
|
"handlebars": "^4.7.8",
|
|
21
23
|
"mongodb": "^6.4.0",
|
|
22
24
|
"nodemon": "^3.1.0",
|
|
23
|
-
"tango-api-schema": "^2.0.
|
|
24
|
-
"tango-app-api-middleware": "^1.0.
|
|
25
|
+
"tango-api-schema": "^2.0.56",
|
|
26
|
+
"tango-app-api-middleware": "^1.0.41-dev",
|
|
25
27
|
"winston": "^3.12.0",
|
|
26
28
|
"winston-daily-rotate-file": "^5.0.0"
|
|
27
29
|
},
|
|
@@ -101,6 +101,7 @@ export async function infraCard( req, res ) {
|
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
103
|
let ticketList = await aggregateTangoTicket( query );
|
|
104
|
+
|
|
104
105
|
let issueList = await findinfraReason( { parentId: { '$exists': false } } );
|
|
105
106
|
const categoryCounts = {};
|
|
106
107
|
let response;
|
|
@@ -421,7 +422,7 @@ export async function InstallationIssuesTable( req, res ) {
|
|
|
421
422
|
}
|
|
422
423
|
if ( req.body.export ) {
|
|
423
424
|
const exportdata = [];
|
|
424
|
-
|
|
425
|
+
storesList.forEach( ( element ) => {
|
|
425
426
|
exportdata.push( {
|
|
426
427
|
'CLIENT NAME': element.clientName,
|
|
427
428
|
'STORE ID': element.storeId,
|
|
@@ -494,6 +495,10 @@ export async function hourWiseDownClients( req, res ) {
|
|
|
494
495
|
let clientdata = await livecountCheck( data, inputData );
|
|
495
496
|
result.push( clientdata[0] );
|
|
496
497
|
}
|
|
498
|
+
if ( req.body.export && result.length > 0 ) {
|
|
499
|
+
await download( result, res );
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
497
502
|
res.sendSuccess( { count: count.length, result: result } );
|
|
498
503
|
} catch ( error ) {
|
|
499
504
|
logger.error( { error: error, function: 'hourWiseDownClients' } );
|
|
@@ -639,6 +644,10 @@ export async function hourWiseDownstores( req, res ) {
|
|
|
639
644
|
let storedata = await downStoresCheck( data, inputData );
|
|
640
645
|
result.push( storedata[0] );
|
|
641
646
|
}
|
|
647
|
+
if ( req.body.export && result.length > 0 ) {
|
|
648
|
+
await download( result, res );
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
642
651
|
res.sendSuccess( { count: count.length, result: result } );
|
|
643
652
|
} catch ( error ) {
|
|
644
653
|
logger.error( { error: error, function: 'hourWiseDownstores' } );
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { createTangoTicket, findOneTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
|
|
4
4
|
import { createinfraReason, findinfraReason } from '../services/infraReason.service.js';
|
|
5
5
|
import { updateOneStore } from '../services/store.service.js';
|
|
6
|
-
import { logger, fileUpload } from 'tango-app-api-middleware';
|
|
6
|
+
import { logger, fileUpload, signedUrl } from 'tango-app-api-middleware';
|
|
7
7
|
import dayjs from 'dayjs';
|
|
8
8
|
export async function createTicket( req, res ) {
|
|
9
9
|
try {
|
|
@@ -96,7 +96,7 @@ export async function secondaryReason( req, res ) {
|
|
|
96
96
|
|
|
97
97
|
export async function updateTicketIssue( req, res ) {
|
|
98
98
|
try {
|
|
99
|
-
let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketActivity': req.body.ticketActivity, 'ticketDetails.issueIdentifiedDate': new Date(), 'ticketDetails.issueIdentifiedBy': req.body.issueIdentifiedBy, 'ticketDetails.issueStatus': 'identified' } );
|
|
99
|
+
let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketActivity': req.body.ticketActivity, 'ticketDetails.issueIdentifiedDate': new Date(), 'ticketDetails.issueIdentifiedBy': req.body.issueIdentifiedBy, 'ticketDetails.issueStatus': 'identified', 'status': 'inprogress' } );
|
|
100
100
|
if ( updateTicket ) {
|
|
101
101
|
res.sendSuccess( 'Ticket Updated Successfully' );
|
|
102
102
|
}
|
|
@@ -108,8 +108,21 @@ export async function updateTicketIssue( req, res ) {
|
|
|
108
108
|
|
|
109
109
|
export async function viewTicket( req, res ) {
|
|
110
110
|
try {
|
|
111
|
-
let ticket = await findOneTangoTicket( { ticketId: req.body.ticketId }, { ticketId: 1, status: 1, ticketActivity: 1 } );
|
|
112
|
-
if ( ticket ) {
|
|
111
|
+
let ticket = await findOneTangoTicket( { ticketId: req.body.ticketId }, { ticketId: 1, status: 1, ticketDetails: 1, basicDetails: 1, ticketActivity: 1, createdAt: 1, attachments: 1 } );
|
|
112
|
+
if ( ticket.attachments && ticket.attachments.length > 0 ) {
|
|
113
|
+
for ( let index in ticket.attachments ) {
|
|
114
|
+
if ( ticket.attachments.hasOwnProperty( index ) ) {
|
|
115
|
+
let file = ticket.attachments[index];
|
|
116
|
+
let params = {
|
|
117
|
+
Bucket: 'tango-client-sandbox',
|
|
118
|
+
file_path: file.filePath,
|
|
119
|
+
};
|
|
120
|
+
let attachments = await signedUrl( params );
|
|
121
|
+
ticket.attachments[index].signedUrl = attachments;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
res.sendSuccess( ticket );
|
|
125
|
+
} else {
|
|
113
126
|
res.sendSuccess( ticket );
|
|
114
127
|
}
|
|
115
128
|
} catch ( error ) {
|
|
@@ -119,7 +132,7 @@ export async function viewTicket( req, res ) {
|
|
|
119
132
|
}
|
|
120
133
|
export async function AlertTicketReply( req, res ) {
|
|
121
134
|
try {
|
|
122
|
-
req.body.ticketActivity = req.body.ticketActivity.filter( ( data ) => data.action !='statusCheck' );
|
|
135
|
+
req.body.ticketActivity = req.body.ticketActivity.filter( ( data ) => data.action != 'statusCheck' );
|
|
123
136
|
req.body.ticketActivity.push( {
|
|
124
137
|
actionType: 'statusCheckReply',
|
|
125
138
|
actionBy: 'Tango',
|
|
@@ -139,15 +152,32 @@ export async function AlertTicketReply( req, res ) {
|
|
|
139
152
|
}
|
|
140
153
|
export async function uploadAttachments( req, res ) {
|
|
141
154
|
try {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
155
|
+
if ( req.files.img && req.files.img.length > 0 ) {
|
|
156
|
+
let attachments = [];
|
|
157
|
+
for ( let singleImg in req.files.img ) {
|
|
158
|
+
if ( req.files.img.hasOwnProperty( singleImg ) ) {
|
|
159
|
+
let params = {
|
|
160
|
+
Bucket: 'tango-client-sandbox',
|
|
161
|
+
Key: req.params.ticketId + '/',
|
|
162
|
+
ContentType: 'multipart/form-data',
|
|
163
|
+
body: req.files.img[singleImg].data,
|
|
164
|
+
fileName: req.files.img[singleImg].name,
|
|
165
|
+
};
|
|
166
|
+
let upload = await fileUpload( params );
|
|
167
|
+
if ( upload ) {
|
|
168
|
+
let getObject = {
|
|
169
|
+
fileName: req.files.img[singleImg].name,
|
|
170
|
+
filePath: req.params.ticketId + '/' + req.files.img[singleImg].name,
|
|
171
|
+
};
|
|
172
|
+
attachments.push( getObject );
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
let updateTicket = await updateOneTangoTicket( { ticketId: req.params.ticketId }, { attachments: attachments } );
|
|
177
|
+
if ( updateTicket ) {
|
|
178
|
+
res.sendSuccess( 'Uploaded successfully' );
|
|
179
|
+
}
|
|
180
|
+
}
|
|
151
181
|
} catch ( error ) {
|
|
152
182
|
logger.error( { error: error, function: 'uploadAttachments' } );
|
|
153
183
|
return res.sendError( error, 500 );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { logger, getOpenSearchData } from 'tango-app-api-middleware';
|
|
2
|
+
import { logger, getOpenSearchData, download } from 'tango-app-api-middleware';
|
|
3
3
|
import { aggregateTangoTicket } from '../services/tangoTicket.service.js';
|
|
4
4
|
import { findOneStore } from '../services/store.service.js';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
@@ -8,14 +8,18 @@ export async function storeTicketList( req, res ) {
|
|
|
8
8
|
try {
|
|
9
9
|
let query = [ {
|
|
10
10
|
$match: {
|
|
11
|
-
|
|
11
|
+
$and: [
|
|
12
|
+
{ 'basicDetails.storeId': req.body.storeId },
|
|
13
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
14
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
15
|
+
],
|
|
12
16
|
},
|
|
13
17
|
},
|
|
14
18
|
{
|
|
15
19
|
$project: {
|
|
16
20
|
storeId: '$basicDetails.storeId',
|
|
17
21
|
status: 1,
|
|
18
|
-
Date: { $dateToString: { format: '%d-%m-%Y', date: '$
|
|
22
|
+
Date: { $dateToString: { format: '%d-%m-%Y', date: '$createdAt' } },
|
|
19
23
|
issueClosedDate: 1,
|
|
20
24
|
ticketId: 1,
|
|
21
25
|
issueStatus: '$ticketDetails.issueStatus',
|
|
@@ -53,7 +57,30 @@ export async function storeTicketList( req, res ) {
|
|
|
53
57
|
},
|
|
54
58
|
},
|
|
55
59
|
];
|
|
60
|
+
|
|
61
|
+
if ( req.body.filter && req.body.filter !== '' ) {
|
|
62
|
+
query.push( {
|
|
63
|
+
$match: {
|
|
64
|
+
primaryIssue: req.body.filter,
|
|
65
|
+
},
|
|
66
|
+
} );
|
|
67
|
+
}
|
|
56
68
|
let ticketList = await aggregateTangoTicket( query );
|
|
69
|
+
if ( req.body.export && ticketList.length > 0 ) {
|
|
70
|
+
const exportdata = [];
|
|
71
|
+
ticketList.forEach( ( element ) => {
|
|
72
|
+
exportdata.push( {
|
|
73
|
+
'STORE ID': element.storeId,
|
|
74
|
+
'TICKET ID': element.ticketId,
|
|
75
|
+
'DATE': element.Date,
|
|
76
|
+
'ISSUE CLOSED DATE': element.issueClosedDate,
|
|
77
|
+
'ISSUE': element.primaryIssue,
|
|
78
|
+
'STATUS': element.status,
|
|
79
|
+
} );
|
|
80
|
+
} );
|
|
81
|
+
await download( exportdata, res );
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
57
84
|
if ( ticketList.length ) {
|
|
58
85
|
res.sendSuccess( {
|
|
59
86
|
count: ticketList.length,
|
|
@@ -72,8 +99,13 @@ export async function storeTicketcard( req, res ) {
|
|
|
72
99
|
try {
|
|
73
100
|
let query = [ {
|
|
74
101
|
$match: {
|
|
75
|
-
|
|
76
|
-
|
|
102
|
+
$and: [
|
|
103
|
+
{ 'basicDetails.storeId': req.body.storeId },
|
|
104
|
+
{ 'ticketDetails.issueStatus': 'identified' },
|
|
105
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
106
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
107
|
+
],
|
|
108
|
+
|
|
77
109
|
},
|
|
78
110
|
},
|
|
79
111
|
{
|
|
@@ -309,6 +341,10 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
309
341
|
const appStatus = await getOpenSearchData( 'edgeapp_systemlogs', appStatusQuery );
|
|
310
342
|
obj.appStatus = appStatus.body.hits.hits.length > 0 ? appStatus.body.hits.hits[0]._source.data.message : '';
|
|
311
343
|
}
|
|
344
|
+
if ( req.body.export ) {
|
|
345
|
+
await download( timeSlots, res );
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
312
348
|
res.sendSuccess( timeSlots );
|
|
313
349
|
} catch ( error ) {
|
|
314
350
|
logger.error( { error: error, function: 'edgeAppLog' } );
|
|
@@ -5,6 +5,7 @@ import { findOneUser } from '../services/user.service.js';
|
|
|
5
5
|
import { aggregateStore } from '../services/store.service.js';
|
|
6
6
|
|
|
7
7
|
import mongoose from 'mongoose';
|
|
8
|
+
import dayjs from 'dayjs';
|
|
8
9
|
|
|
9
10
|
export async function userTakeTicket( req, res ) {
|
|
10
11
|
try {
|
|
@@ -38,7 +39,6 @@ export async function userTicketList( req, res ) {
|
|
|
38
39
|
],
|
|
39
40
|
},
|
|
40
41
|
} ];
|
|
41
|
-
|
|
42
42
|
if ( req.body.status != 'closed' ) {
|
|
43
43
|
query.push( {
|
|
44
44
|
$match: {
|
|
@@ -51,9 +51,7 @@ export async function userTicketList( req, res ) {
|
|
|
51
51
|
} else {
|
|
52
52
|
query.push( {
|
|
53
53
|
$match: {
|
|
54
|
-
$
|
|
55
|
-
{ createdAt: { $gte: new Date() } },
|
|
56
|
-
],
|
|
54
|
+
issueClosedDate: { $gte: new Date( dayjs().format( 'YYYY-MM-DD' ) ) },
|
|
57
55
|
},
|
|
58
56
|
} );
|
|
59
57
|
}
|
|
@@ -94,7 +92,41 @@ export async function userTicketList( req, res ) {
|
|
|
94
92
|
infraIssue: '$primaryIssue.reasons.primaryIssue',
|
|
95
93
|
},
|
|
96
94
|
} );
|
|
95
|
+
|
|
96
|
+
if ( req.body.searchValue && req.body.searchValue !== '' ) {
|
|
97
|
+
query.push( {
|
|
98
|
+
$match: {
|
|
99
|
+
$or: [
|
|
100
|
+
{ storeId: { $regex: req.body.searchValue, $options: 'i' } },
|
|
101
|
+
{ infraIssue: { $regex: req.body.searchValue, $options: 'i' } },
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
} );
|
|
105
|
+
}
|
|
106
|
+
if ( req.body.filter && req.body.filter !== '' ) {
|
|
107
|
+
query.push( {
|
|
108
|
+
$match: {
|
|
109
|
+
$or: [
|
|
110
|
+
{ issueStatus: req.body.filter },
|
|
111
|
+
{ infraIssue: req.body.filter },
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
} );
|
|
115
|
+
}
|
|
97
116
|
let ticketList = await aggregateTangoTicket( query );
|
|
117
|
+
if ( req.body.export ) {
|
|
118
|
+
const exportdata = [];
|
|
119
|
+
ticketList.forEach( ( element ) => {
|
|
120
|
+
exportdata.push( {
|
|
121
|
+
'DATE': element.Date,
|
|
122
|
+
'TICKET ID': element.ticketId,
|
|
123
|
+
'STORE ID': element.storeId,
|
|
124
|
+
'ISSUE': element.issueStatus,
|
|
125
|
+
} );
|
|
126
|
+
} );
|
|
127
|
+
await download( exportdata, res );
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
98
130
|
if ( ticketList.length ) {
|
|
99
131
|
res.sendSuccess( {
|
|
100
132
|
count: ticketList.length,
|
|
@@ -108,6 +140,42 @@ export async function userTicketList( req, res ) {
|
|
|
108
140
|
return res.sendError( error, 500 );
|
|
109
141
|
}
|
|
110
142
|
}
|
|
143
|
+
export async function activeTicketList( req, res ) {
|
|
144
|
+
try {
|
|
145
|
+
let query = [ {
|
|
146
|
+
$match: {
|
|
147
|
+
$and: [
|
|
148
|
+
{ 'status': { $in: [ 'open', 'inprogress' ] } },
|
|
149
|
+
{ issueType: req.body.issueType },
|
|
150
|
+
{ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
}, {
|
|
154
|
+
$project: {
|
|
155
|
+
storeId: '$basicDetails.storeId',
|
|
156
|
+
ticketId: 1,
|
|
157
|
+
storeName: '$basicDetails.storeName',
|
|
158
|
+
address: { $ifNull: [ '$basicDetails.address', '' ] },
|
|
159
|
+
status: 1,
|
|
160
|
+
},
|
|
161
|
+
} ];
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
let ticketList = await aggregateTangoTicket( query );
|
|
165
|
+
|
|
166
|
+
if ( ticketList.length ) {
|
|
167
|
+
res.sendSuccess( {
|
|
168
|
+
count: ticketList.length,
|
|
169
|
+
data: ticketList,
|
|
170
|
+
} );
|
|
171
|
+
} else {
|
|
172
|
+
return res.sendError( 'NO data', 204 );
|
|
173
|
+
}
|
|
174
|
+
} catch ( error ) {
|
|
175
|
+
logger.error( { error: error, function: 'activeTicketList' } );
|
|
176
|
+
return res.sendError( error, 500 );
|
|
177
|
+
}
|
|
178
|
+
}
|
|
111
179
|
export async function basicDetails( req, res ) {
|
|
112
180
|
try {
|
|
113
181
|
let user = await findOneUser( { _id: new mongoose.Types.ObjectId( req.body.userId ) }, { userName: 1, userType: 1 } );
|
|
@@ -141,56 +209,111 @@ export async function workHistory( req, res ) {
|
|
|
141
209
|
{ 'status': 'closed' },
|
|
142
210
|
{ issueType: req.body.issueType },
|
|
143
211
|
{ 'ticketDetails.addressingUser': new mongoose.Types.ObjectId( req.body.userId ) },
|
|
144
|
-
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
145
|
-
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
146
212
|
],
|
|
147
213
|
},
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
214
|
+
} ];
|
|
215
|
+
|
|
216
|
+
if ( req.body.dateFilter&&req.body.dateFilter !='' ) {
|
|
217
|
+
if ( req.body.dateFilter === 'issueIdentifiedDate' ) {
|
|
218
|
+
query.push(
|
|
219
|
+
{
|
|
220
|
+
$match: {
|
|
221
|
+
$and: [
|
|
222
|
+
{ 'ticketDetails.issueIdentifiedDate': { $gte: new Date( req.body.fromDate ) } },
|
|
223
|
+
{ 'ticketDetails.issueIdentifiedDate': { $lte: new Date( req.body.toDate ) } },
|
|
224
|
+
],
|
|
225
|
+
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
);
|
|
229
|
+
} else if ( req.body.dateFilter === 'closedDate' ) {
|
|
230
|
+
query.push(
|
|
231
|
+
{
|
|
232
|
+
$match: {
|
|
233
|
+
$and: [
|
|
234
|
+
{ 'issueClosedDate': { $gte: new Date( req.body.fromDate ) } },
|
|
235
|
+
{ 'issueClosedDate': { $lte: new Date( req.body.toDate ) } },
|
|
236
|
+
],
|
|
237
|
+
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
);
|
|
241
|
+
} else {
|
|
242
|
+
query.push(
|
|
243
|
+
{
|
|
244
|
+
$match: {
|
|
245
|
+
$and: [
|
|
246
|
+
{ createdAt: { $gte: new Date( req.body.fromDate ) } },
|
|
247
|
+
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
248
|
+
],
|
|
249
|
+
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if ( req.body.storeFilter&&req.body.storeFilter.length>0 ) {
|
|
257
|
+
query.push(
|
|
258
|
+
{
|
|
259
|
+
$match: {
|
|
260
|
+
'basicDetails.storeId': { $in: req.body.storeFilter } },
|
|
261
|
+
},
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
query.push(
|
|
265
|
+
{
|
|
266
|
+
$project: {
|
|
267
|
+
storeId: '$basicDetails.storeId',
|
|
268
|
+
storeName: '$basicDetails.storeName',
|
|
269
|
+
clientId: '$basicDetails.clientId',
|
|
270
|
+
clientName: '$basicDetails.clientName',
|
|
271
|
+
issueDate: { $dateToString: { format: '%Y-%m-%d', date: '$createdAt' } },
|
|
272
|
+
issueClosedDate: { $dateToString: { format: '%Y-%m-%d', date: '$issueClosedDate' } },
|
|
273
|
+
issueIdentifiedDate: { $dateToString: { format: '%Y-%m-%d', date: '$ticketDetails.issueIdentifiedDate' } },
|
|
274
|
+
ticketId: 1,
|
|
275
|
+
issueStatus: '$ticketDetails.issueStatus',
|
|
276
|
+
ticketType: '$ticketDetails.ticketType',
|
|
277
|
+
primaryIssue: {
|
|
278
|
+
$filter: {
|
|
279
|
+
input: '$ticketActivity',
|
|
280
|
+
as: 'item',
|
|
281
|
+
cond: { $eq: [ '$$item.actionType', 'issueUpdate' ] },
|
|
282
|
+
},
|
|
283
|
+
},
|
|
166
284
|
},
|
|
167
285
|
},
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
286
|
+
{
|
|
287
|
+
$unwind: {
|
|
288
|
+
path: '$primaryIssue', preserveNullAndEmptyArrays: true,
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
$unwind: {
|
|
293
|
+
path: '$primaryIssue.reasons', preserveNullAndEmptyArrays: true,
|
|
294
|
+
},
|
|
295
|
+
}, {
|
|
296
|
+
$project: {
|
|
297
|
+
storeId: 1,
|
|
298
|
+
storeName: 1,
|
|
299
|
+
clientId: 1,
|
|
300
|
+
clientName: 1,
|
|
301
|
+
issueDate: 1,
|
|
302
|
+
issueIdentifiedDate: 1,
|
|
303
|
+
issueClosedDate: 1,
|
|
304
|
+
ticketId: 1,
|
|
305
|
+
issueStatus: 1,
|
|
306
|
+
ticketType: 1,
|
|
307
|
+
infraIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '' ] },
|
|
308
|
+
},
|
|
309
|
+
} );
|
|
310
|
+
if ( req.body.issueFilter && req.body.issueFilter !== '' ) {
|
|
311
|
+
query.push( {
|
|
312
|
+
$match: {
|
|
313
|
+
infraIssue: req.body.issueFilter,
|
|
314
|
+
},
|
|
315
|
+
} );
|
|
316
|
+
}
|
|
194
317
|
if ( req.body.searchValue && req.body.searchValue !== '' ) {
|
|
195
318
|
query.push( {
|
|
196
319
|
$match: {
|
|
@@ -258,7 +381,6 @@ export async function storeInfraList( req, res ) {
|
|
|
258
381
|
$match: {
|
|
259
382
|
$and: [
|
|
260
383
|
{ clientId: { $in: req.body.clientId } },
|
|
261
|
-
{ createdAt: { $lte: new Date( req.body.toDate ) } },
|
|
262
384
|
],
|
|
263
385
|
},
|
|
264
386
|
},
|
|
@@ -290,13 +412,34 @@ export async function storeInfraList( req, res ) {
|
|
|
290
412
|
},
|
|
291
413
|
},
|
|
292
414
|
];
|
|
293
|
-
if ( req.body.storeId && req.body.storeId.length>0 ) {
|
|
415
|
+
if ( req.body.storeId && req.body.storeId.length > 0 ) {
|
|
294
416
|
query.push( {
|
|
295
417
|
$match: {
|
|
296
418
|
storeId: { $in: req.body.storeId },
|
|
297
419
|
},
|
|
298
420
|
} );
|
|
299
421
|
}
|
|
422
|
+
if ( req.body.country && req.body.country.length > 0 ) {
|
|
423
|
+
query.push( {
|
|
424
|
+
$match: {
|
|
425
|
+
country: { $in: req.body.country },
|
|
426
|
+
},
|
|
427
|
+
} );
|
|
428
|
+
}
|
|
429
|
+
if ( req.body.state && req.body.state.length > 0 ) {
|
|
430
|
+
query.push( {
|
|
431
|
+
$match: {
|
|
432
|
+
state: { $in: req.body.state },
|
|
433
|
+
},
|
|
434
|
+
} );
|
|
435
|
+
}
|
|
436
|
+
if ( req.body.city && req.body.city.length > 0 ) {
|
|
437
|
+
query.push( {
|
|
438
|
+
$match: {
|
|
439
|
+
city: { $in: req.body.city },
|
|
440
|
+
},
|
|
441
|
+
} );
|
|
442
|
+
}
|
|
300
443
|
if ( req.body.searchValue && req.body.searchValue !== '' ) {
|
|
301
444
|
query.push( {
|
|
302
445
|
$match: {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { isAllowedSessionHandler } from 'tango-app-api-middleware';
|
|
3
|
-
import { userTakeTicket, userTicketList, basicDetails, workHistory, storeInfraList } from '../controllers/userInfra.controller.js';
|
|
3
|
+
import { userTakeTicket, userTicketList, activeTicketList, basicDetails, workHistory, storeInfraList } from '../controllers/userInfra.controller.js';
|
|
4
4
|
|
|
5
5
|
export const userInfraRouter = express.Router();
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
userInfraRouter.post( '/userTakeTicket', isAllowedSessionHandler, userTakeTicket );
|
|
9
9
|
userInfraRouter.post( '/userTicketList', isAllowedSessionHandler, userTicketList );
|
|
10
|
+
userInfraRouter.post( '/activeTicketList', isAllowedSessionHandler, activeTicketList );
|
|
10
11
|
userInfraRouter.post( '/basicDetails', isAllowedSessionHandler, basicDetails );
|
|
11
12
|
userInfraRouter.post( '/workHistory', isAllowedSessionHandler, workHistory );
|
|
12
13
|
userInfraRouter.post( '/storeInfraList', isAllowedSessionHandler, storeInfraList );
|
|
@@ -18,6 +18,7 @@ export async function validateDetails( req, res, next ) {
|
|
|
18
18
|
req.body.basicDetails = {
|
|
19
19
|
storeId: req.body.storeId,
|
|
20
20
|
storeName: store.storeName,
|
|
21
|
+
address: store.storeProfile&&store.storeProfile.address?store.storeProfile.address:'',
|
|
21
22
|
clientId: store.clientId,
|
|
22
23
|
clientName: client.clientName,
|
|
23
24
|
};
|