shuttlepro-shared 1.4.14 → 1.4.15
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.
|
@@ -243,8 +243,11 @@ class CallRepository {
|
|
|
243
243
|
$group: {
|
|
244
244
|
_id: "$agentId",
|
|
245
245
|
totalCalls: { $sum: 1 },
|
|
246
|
-
|
|
247
|
-
$sum: { $cond: [{ $eq: ["$status", "
|
|
246
|
+
abandoned: {
|
|
247
|
+
$sum: { $cond: [{ $eq: ["$status", "pending"] }, 1, 0] },
|
|
248
|
+
},
|
|
249
|
+
abandoned: {
|
|
250
|
+
$sum: { $cond: [{ $eq: ["$status", "abandoned"] }, 1, 0] },
|
|
248
251
|
},
|
|
249
252
|
ended: {
|
|
250
253
|
$sum: { $cond: [{ $eq: ["$status", "ended"] }, 1, 0] },
|
|
@@ -255,6 +258,42 @@ class CallRepository {
|
|
|
255
258
|
]);
|
|
256
259
|
}
|
|
257
260
|
|
|
261
|
+
async getAgentStatsByAgentId(workspaceId, agentId, from, to) {
|
|
262
|
+
const result = await Call.aggregate([
|
|
263
|
+
{
|
|
264
|
+
$match: {
|
|
265
|
+
workspaceId,
|
|
266
|
+
agentId,
|
|
267
|
+
createdAt: { $gte: from, $lte: to },
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
$group: {
|
|
272
|
+
_id: "$agentId",
|
|
273
|
+
totalCalls: { $sum: 1 },
|
|
274
|
+
pending: {
|
|
275
|
+
$sum: { $cond: [{ $eq: ["$status", "pending"] }, 1, 0] },
|
|
276
|
+
},
|
|
277
|
+
abandoned: {
|
|
278
|
+
$sum: { $cond: [{ $eq: ["$status", "abandoned"] }, 1, 0] },
|
|
279
|
+
},
|
|
280
|
+
ended: {
|
|
281
|
+
$sum: { $cond: [{ $eq: ["$status", "ended"] }, 1, 0] },
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
]);
|
|
286
|
+
return (
|
|
287
|
+
result[0] || {
|
|
288
|
+
_id: agentId,
|
|
289
|
+
totalCalls: 0,
|
|
290
|
+
pending: 0,
|
|
291
|
+
abandoned: 0,
|
|
292
|
+
ended: 0,
|
|
293
|
+
}
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
258
297
|
// Daily call summary
|
|
259
298
|
async getDailySummary(workspaceId, from, to) {
|
|
260
299
|
return Call.aggregate([
|