shuttlepro-shared 1.4.20 → 1.4.21
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.
|
@@ -281,17 +281,23 @@ class CallRepository {
|
|
|
281
281
|
|
|
282
282
|
// Stats grouped by agent
|
|
283
283
|
async getAgentStats({ from, to }, filters = {}) {
|
|
284
|
-
|
|
285
|
-
const
|
|
284
|
+
// Pakistan offset (+5 hours)
|
|
285
|
+
const PAK_OFFSET = 5 * 60 * 60 * 1000;
|
|
286
|
+
|
|
287
|
+
// convert input to Date objects
|
|
288
|
+
const fromDate = new Date(new Date(from).getTime() - PAK_OFFSET);
|
|
289
|
+
const toDate = new Date(new Date(to).getTime() - PAK_OFFSET);
|
|
290
|
+
|
|
291
|
+
// set end of day in Pakistan time
|
|
286
292
|
toDate.setHours(23, 59, 59, 999);
|
|
287
293
|
|
|
294
|
+
console.log({ fromDate, toDate }, filters);
|
|
295
|
+
|
|
288
296
|
const matchStage = {
|
|
289
297
|
createdAt: { $gte: fromDate, $lte: toDate },
|
|
290
298
|
...filters,
|
|
291
299
|
};
|
|
292
300
|
|
|
293
|
-
console.log(matchStage, "matchStage query");
|
|
294
|
-
|
|
295
301
|
const result = await Call.aggregate([
|
|
296
302
|
{ $match: matchStage },
|
|
297
303
|
{
|