tango-app-api-infra 3.0.11 → 3.0.13
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 +2 -2
- package/src/controllers/infra.controllers.js +14 -9
- package/src/controllers/internalInfra.controller.js +26 -4
- package/src/controllers/userInfra.controller.js +75 -0
- package/src/routes/infra.routes.js +4 -3
- package/src/routes/internalInfra.routes.js +3 -1
- package/src/routes/userInfra.routes.js +2 -1
- package/src/services/store.service.js +3 -0
- package/src/validations/infra.validation.js +34 -3
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.13",
|
|
4
4
|
"description": "infra",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"handlebars": "^4.7.8",
|
|
21
21
|
"mongodb": "^6.4.0",
|
|
22
22
|
"nodemon": "^3.1.0",
|
|
23
|
-
"tango-api-schema": "^2.0.
|
|
23
|
+
"tango-api-schema": "^2.0.38",
|
|
24
24
|
"tango-app-api-middleware": "^1.0.18",
|
|
25
25
|
"winston": "^3.12.0",
|
|
26
26
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -24,16 +24,8 @@ export async function createTicket( req, res ) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
27
|
export async function updateStatus( req, res ) {
|
|
29
28
|
try {
|
|
30
|
-
if ( req.body.status == 'closed' ) {
|
|
31
|
-
req.body.issueClosedDate = new Date();
|
|
32
|
-
req.body.infraActivity.push( {
|
|
33
|
-
actionType: 'dataRecived',
|
|
34
|
-
actionBy: 'Tango',
|
|
35
|
-
} );
|
|
36
|
-
}
|
|
37
29
|
if ( req.body.status == 'inprogress' ) {
|
|
38
30
|
req.body.infraActivity.push( {
|
|
39
31
|
actionType: 'statusChange',
|
|
@@ -68,7 +60,7 @@ export async function PrimaryReasons( req, res ) {
|
|
|
68
60
|
try {
|
|
69
61
|
let list = await findinfraReason( { parentId: { $exists: false } }, { name: 1, order: 1 } );
|
|
70
62
|
if ( list.length > 0 ) {
|
|
71
|
-
res.
|
|
63
|
+
res.sendSuccess( {
|
|
72
64
|
count: list.length,
|
|
73
65
|
result: list,
|
|
74
66
|
} );
|
|
@@ -120,3 +112,16 @@ export async function viewTicket( req, res ) {
|
|
|
120
112
|
return res.sendError( error, 500 );
|
|
121
113
|
}
|
|
122
114
|
}
|
|
115
|
+
export async function AlertTicketReply( req, res ) {
|
|
116
|
+
try {
|
|
117
|
+
req.body.infraActivity = req.body.infraActivity.filter( ( data ) => data.action !='statusCheck' );
|
|
118
|
+
req.body.infraActivity.push( {
|
|
119
|
+
actionType: 'statusCheckReply',
|
|
120
|
+
actionBy: 'Tango',
|
|
121
|
+
|
|
122
|
+
} );
|
|
123
|
+
} catch ( error ) {
|
|
124
|
+
logger.error( { error: error, function: 'AlertTicketReply' } );
|
|
125
|
+
return res.sendError( error, 500 );
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -3,7 +3,7 @@ import { logger } from 'tango-app-api-middleware';
|
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import { createClient, findClient } from '../services/client.service.js';
|
|
5
5
|
import { createStore, findStore, updateOneStore } from '../services/store.service.js';
|
|
6
|
-
import { findTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
|
|
6
|
+
import { findTangoTicket, findOneTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
export async function migrateClient() {
|
|
@@ -51,8 +51,6 @@ export async function migrateStores() {
|
|
|
51
51
|
close: oldstores[i].configuration.storeCloseTime,
|
|
52
52
|
timeZone: oldstores[i].timezone,
|
|
53
53
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
54
|
};
|
|
57
55
|
|
|
58
56
|
await createStore( framedStores );
|
|
@@ -116,7 +114,7 @@ export async function openTicketList( req, res ) {
|
|
|
116
114
|
try {
|
|
117
115
|
let openTicketList = await findTangoTicket( { status: { $ne: 'closed' } }, { ticketId: 1, basicDetails: 1, createdAt: 1, updateAt: 1, infraTicketDetails: 1 } );
|
|
118
116
|
if ( openTicketList.length ) {
|
|
119
|
-
res.
|
|
117
|
+
res.sendSuccess( {
|
|
120
118
|
count: openTicketList.length,
|
|
121
119
|
data: openTicketList,
|
|
122
120
|
} );
|
|
@@ -147,3 +145,27 @@ export async function updateRefreshTicket( req, res ) {
|
|
|
147
145
|
res.sendError( error, 500 );
|
|
148
146
|
}
|
|
149
147
|
}
|
|
148
|
+
export async function closeTicket( req, res ) {
|
|
149
|
+
try {
|
|
150
|
+
for ( let ticket of req.body.TicketList ) {
|
|
151
|
+
let getTicket = await findOneTangoTicket( { ticketId: ticket.ticketId } );
|
|
152
|
+
if ( ticket.status == 'closed' ) {
|
|
153
|
+
getTicket.infraActivity.push( {
|
|
154
|
+
actionType: 'dataRecived',
|
|
155
|
+
actionBy: 'Tango',
|
|
156
|
+
} );
|
|
157
|
+
}
|
|
158
|
+
await updateOneTangoTicket( { ticketId: ticket.ticketId },
|
|
159
|
+
{
|
|
160
|
+
status: ticket.status,
|
|
161
|
+
infraActivity: getTicket.infraActivity,
|
|
162
|
+
issueClosedDate: new Date(),
|
|
163
|
+
},
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
res.sendSuccess( 'updated Successfully' );
|
|
167
|
+
} catch ( error ) {
|
|
168
|
+
logger.error( { error: error, function: 'closeTicket' } );
|
|
169
|
+
res.sendError( error, 500 );
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { findOneTangoTicket, updateOneTangoTicket, aggregateTangoTicket, countDocumentsTangoTicket } from '../services/tangoTicket.service.js';
|
|
3
3
|
import { logger } from 'tango-app-api-middleware';
|
|
4
4
|
import { findOneUser } from '../services/user.service.js';
|
|
5
|
+
import { aggregateStore } from '../services/store.service.js';
|
|
6
|
+
|
|
5
7
|
import mongoose from 'mongoose';
|
|
6
8
|
|
|
7
9
|
export async function userTakeTicket( req, res ) {
|
|
@@ -171,3 +173,76 @@ export async function workHistory( req, res ) {
|
|
|
171
173
|
}
|
|
172
174
|
}
|
|
173
175
|
|
|
176
|
+
|
|
177
|
+
export async function storeInfraList( req, res ) {
|
|
178
|
+
try {
|
|
179
|
+
let query = [
|
|
180
|
+
{
|
|
181
|
+
$match: {
|
|
182
|
+
clientId: { $in: req.body.clientId },
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
$project: {
|
|
187
|
+
storeId: 1,
|
|
188
|
+
storeName: 1,
|
|
189
|
+
storeProfile: 1,
|
|
190
|
+
status: 1,
|
|
191
|
+
spocDetails: 1,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
$unwind: {
|
|
196
|
+
path: '$spocDetails', preserveNullAndEmptyArrays: true,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
$group: {
|
|
201
|
+
_id: '$storeId',
|
|
202
|
+
storeId: { $first: '$storeId' },
|
|
203
|
+
storeName: { $first: '$storeName' },
|
|
204
|
+
status: { $first: '$status' },
|
|
205
|
+
city: { $first: '$storeProfile.city' },
|
|
206
|
+
state: { $first: '$storeProfile.state' },
|
|
207
|
+
country: { $first: '$storeProfile.country' },
|
|
208
|
+
spocName: { $first: { $ifNull: [ '$spocDetails.name', '' ] } },
|
|
209
|
+
spocContact: { $first: { $ifNull: [ '$spocDetails.contact', '' ] } },
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
];
|
|
213
|
+
|
|
214
|
+
let count = await aggregateStore( query );
|
|
215
|
+
if ( req.body.limit && req.body.offset && !req.body.export ) {
|
|
216
|
+
query.push(
|
|
217
|
+
{ $skip: ( req.body.offset - 1 ) * req.body.limit },
|
|
218
|
+
{ $limit: Number( req.body.limit ) },
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
let storesList = await aggregateStore( query );
|
|
222
|
+
let infrastoreList = [];
|
|
223
|
+
for ( let store of storesList ) {
|
|
224
|
+
store.downTime = 'NA';
|
|
225
|
+
let infracheck = await findOneTangoTicket( { 'basicDetails.storeId': store.storeId, 'issueDate': new Date() } );
|
|
226
|
+
if ( infracheck ) {
|
|
227
|
+
store.status = 'Infra Issue';
|
|
228
|
+
} else {
|
|
229
|
+
if ( store.status == 'active' ) {
|
|
230
|
+
store.status = 'Live';
|
|
231
|
+
store.statusDetail='Connected';
|
|
232
|
+
} else {
|
|
233
|
+
store.statusDetail='Disconnected';
|
|
234
|
+
store.status = 'Deactivated';
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
infrastoreList.push( store );
|
|
239
|
+
}
|
|
240
|
+
res.sendSuccess( {
|
|
241
|
+
count: count.length,
|
|
242
|
+
result: infrastoreList,
|
|
243
|
+
} );
|
|
244
|
+
} catch ( error ) {
|
|
245
|
+
logger.error( { error: error, function: 'storeInfraList' } );
|
|
246
|
+
return res.sendError( error, 500 );
|
|
247
|
+
}
|
|
248
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
|
-
import { validateDetails, validateTicket, ticketExists, infraReasonExists, InfrastepstoResolve } from '../validations/infra.validation.js';
|
|
4
|
-
import { createTicket, updateStatus, createReason, PrimaryReasons, secondaryReason, updateTicketIssue, viewTicket } from '../controllers/infra.controllers.js';
|
|
3
|
+
import { validateDetails, validateTicket, ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert } from '../validations/infra.validation.js';
|
|
4
|
+
import { createTicket, updateStatus, createReason, PrimaryReasons, secondaryReason, updateTicketIssue, viewTicket, AlertTicketReply } from '../controllers/infra.controllers.js';
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
export const infraRouter = express.Router();
|
|
@@ -11,7 +11,8 @@ infraRouter.post( '/updateStatus', ticketExists, updateStatus );
|
|
|
11
11
|
infraRouter.post( '/createReason', createReason );
|
|
12
12
|
infraRouter.get( '/PrimaryReasons', PrimaryReasons );
|
|
13
13
|
infraRouter.post( '/secondaryReason', secondaryReason );
|
|
14
|
-
infraRouter.post( '/updateTicketIssue', ticketExists, infraReasonExists, InfrastepstoResolve, updateTicketIssue );
|
|
14
|
+
infraRouter.post( '/updateTicketIssue', ticketExists, infraReasonExists, InfrastepstoResolve, InfraAlert, updateTicketIssue );
|
|
15
15
|
infraRouter.post( '/viewTicket', ticketExists, viewTicket );
|
|
16
|
+
infraRouter.post( '/AlertTicketReply', ticketExists, AlertTicketReply );
|
|
16
17
|
|
|
17
18
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import {
|
|
4
4
|
migrateClient, migrateStores, basicList, clientList, setTicketTime, downStoresList,
|
|
5
|
-
openTicketList, assigntoUser, updateRefreshTicket,
|
|
5
|
+
openTicketList, assigntoUser, updateRefreshTicket, closeTicket,
|
|
6
6
|
} from '../controllers/internalInfra.controller.js';
|
|
7
7
|
|
|
8
8
|
export const internalInfraRouter = express.Router();
|
|
@@ -16,4 +16,6 @@ internalInfraRouter.post( '/downStoresList', downStoresList );
|
|
|
16
16
|
internalInfraRouter.get( '/openTicketList', openTicketList );
|
|
17
17
|
internalInfraRouter.post( '/assigntoUser', assigntoUser );
|
|
18
18
|
internalInfraRouter.post( '/updateRefreshTicket', updateRefreshTicket );
|
|
19
|
+
internalInfraRouter.post( '/closeTicket', closeTicket );
|
|
20
|
+
|
|
19
21
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
|
-
import { userTakeTicket, userTicketList, basicDetails, workHistory } from '../controllers/userInfra.controller.js';
|
|
2
|
+
import { userTakeTicket, userTicketList, basicDetails, workHistory, storeInfraList } from '../controllers/userInfra.controller.js';
|
|
3
3
|
|
|
4
4
|
export const userInfraRouter = express.Router();
|
|
5
5
|
|
|
@@ -8,5 +8,6 @@ userInfraRouter.post( '/userTakeTicket', userTakeTicket );
|
|
|
8
8
|
userInfraRouter.post( '/userTicketList', userTicketList );
|
|
9
9
|
userInfraRouter.post( '/basicDetails', basicDetails );
|
|
10
10
|
userInfraRouter.post( '/workHistory', workHistory );
|
|
11
|
+
userInfraRouter.post( '/storeInfraList', storeInfraList );
|
|
11
12
|
|
|
12
13
|
|
|
@@ -20,3 +20,6 @@ export async function updateOneStore( query, data ) {
|
|
|
20
20
|
export async function countDocumentsStore( query ) {
|
|
21
21
|
return await dataModel.storeModel.countDocuments( query );
|
|
22
22
|
}
|
|
23
|
+
export async function aggregateStore( query ) {
|
|
24
|
+
return await dataModel.storeModel.aggregate( query );
|
|
25
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
|
-
import { findOneTangoTicket } from '../services/tangoTicket.service.js';
|
|
2
|
+
import { findOneTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
|
|
3
3
|
import { findOneClient } from '../services/client.service.js';
|
|
4
|
-
import { findOneStore } from '../services/store.service.js';
|
|
4
|
+
import { findOneStore, updateOneStore } from '../services/store.service.js';
|
|
5
5
|
import { findOneinfraReason } from '../services/infraReason.service.js';
|
|
6
6
|
import { logger } from 'tango-app-api-middleware';
|
|
7
7
|
|
|
@@ -59,6 +59,7 @@ export async function ticketExists( req, res, next ) {
|
|
|
59
59
|
if ( !Ticket ) {
|
|
60
60
|
return res.sendError( 'Ticket Not Found', 204 );
|
|
61
61
|
}
|
|
62
|
+
req.body.basicDetails = Ticket.basicDetails;
|
|
62
63
|
req.body.infraActivity = Ticket.infraActivity;
|
|
63
64
|
next();
|
|
64
65
|
} catch ( error ) {
|
|
@@ -136,7 +137,37 @@ export async function InfrastepstoResolve( req, res, next ) {
|
|
|
136
137
|
} );
|
|
137
138
|
next();
|
|
138
139
|
} catch ( error ) {
|
|
139
|
-
logger.error( { error: error, function: '
|
|
140
|
+
logger.error( { error: error, function: 'InfrastepstoResolve' } );
|
|
141
|
+
return res.sendError( error, 500 );
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
export async function InfraAlert( req, res, next ) {
|
|
147
|
+
try {
|
|
148
|
+
if ( req.body.hibernationDays ) {
|
|
149
|
+
req.body.hibernationDays = dayjs().add( req.body.hibernationDays, 'days' ).format( 'YYYY-MM-DD' );
|
|
150
|
+
await updateOneStore( { storeId: req.body.basicDetails.storeId }, { 'ticketConfigs.hibernation': new Date( req.body.hibernationDays ) } );
|
|
151
|
+
req.body.infraActivity.push( {
|
|
152
|
+
actionType: 'statusCheckReply',
|
|
153
|
+
actionBy: 'Tango',
|
|
154
|
+
hibernationDays: req.body.hibernationDays,
|
|
155
|
+
} );
|
|
156
|
+
await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'hibernation': new Date( req.body.hibernationDays ) } );
|
|
157
|
+
} else {
|
|
158
|
+
let client = await findOneClient( { clientId: req.body.basicDetails.clientId }, { ticketConfigs: 1 } );
|
|
159
|
+
let statusCheckAlertTime = dayjs().add( client.ticketConfigs.statusCheckAlert, 'hours' ).format( 'YYYY-MM-DD hh:mm' );
|
|
160
|
+
req.body.infraActivity.push( {
|
|
161
|
+
actionType: 'statusCheck',
|
|
162
|
+
actionBy: 'Tango',
|
|
163
|
+
statusCheckAlertTime: statusCheckAlertTime,
|
|
164
|
+
} );
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
next();
|
|
168
|
+
} catch ( error ) {
|
|
169
|
+
logger.error( { error: error, function: 'InfraAlert' } );
|
|
140
170
|
return res.sendError( error, 500 );
|
|
141
171
|
}
|
|
142
172
|
};
|
|
173
|
+
|