generated from lykmapipo/iso-lib-starter
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(build): bundle library for testing
- Loading branch information
1 parent
eecd42f
commit c9fcafe
Showing
2 changed files
with
58 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -312,7 +312,7 @@ const getBaseAggregation = criteria => { | |
}; | ||
|
||
/* constants */ | ||
const times = { | ||
const METRIC_TIMES = { | ||
maximumAssignTime: { $max: '$assignTime' }, | ||
minimumAssignTime: { $min: '$assignTime' }, | ||
averageAssignTime: { $avg: '$assignTime' }, | ||
|
@@ -337,13 +337,16 @@ const times = { | |
maximumConfirmTime: { $max: '$confirmTime' }, | ||
minimumConfirmTime: { $min: '$confirmTime' }, | ||
averageConfirmTime: { $avg: '$confirmTime' }, | ||
maximumCallTime: { $max: '$call.duration.milliseconds' }, | ||
minimumCallTime: { $min: '$call.duration.milliseconds' }, | ||
averageCallTime: { $avg: '$call.duration.milliseconds' }, | ||
}; | ||
|
||
/** | ||
* @namespace OVERALL_FACET | ||
* @description Facet for service requests overall general breakdown | ||
* | ||
* @version 0.1.0 | ||
* @version 0.2.0 | ||
* @since 0.1.0 | ||
*/ | ||
const OVERALL_FACET = { | ||
|
@@ -358,9 +361,7 @@ const OVERALL_FACET = { | |
}, | ||
late: { $sum: '$late' }, | ||
count: { $sum: 1 }, | ||
averageResolveTime: { $avg: '$ttr.milliseconds' }, | ||
averageAttendTime: { $avg: '$call.duration.milliseconds' }, | ||
...times, | ||
...METRIC_TIMES, | ||
}, | ||
}, | ||
{ | ||
|
@@ -375,7 +376,7 @@ const OVERALL_FACET = { | |
* @namespace PRIORITY_FACET | ||
* @description Facet for service requests breakdown based on their priorities | ||
* | ||
* @version 0.1.0 | ||
* @version 0.2.0 | ||
* @since 0.1.0 | ||
*/ | ||
const JURISDICTION_FACET = { | ||
|
@@ -392,24 +393,7 @@ const JURISDICTION_FACET = { | |
phone: { $first: '$jurisdiction.phone' }, | ||
color: { $first: '$jurisdiction.color' }, | ||
count: { $sum: 1 }, | ||
averageResolveTime: { $avg: '$ttr.milliseconds' }, | ||
averageAttendTime: { $avg: '$call.duration.milliseconds' }, | ||
}, | ||
}, | ||
{ | ||
$project: { | ||
_id: 1, | ||
pending: 1, | ||
resolved: 1, | ||
late: 1, | ||
unattended: 1, | ||
name: 1, | ||
email: 1, | ||
phone: 1, | ||
color: 1, | ||
count: 1, | ||
averageResolveTime: 1, | ||
averageAttendTime: 1, | ||
...METRIC_TIMES, | ||
}, | ||
}, | ||
{ | ||
|
@@ -440,17 +424,6 @@ const STATUS_FACET = { | |
resolved: { $sum: '$resolved' }, | ||
}, | ||
}, | ||
{ | ||
$project: { | ||
_id: 1, | ||
name: 1, | ||
weight: 1, | ||
color: 1, | ||
count: 1, | ||
pending: 1, | ||
resolved: 1, | ||
}, | ||
}, | ||
{ $sort: { weight: 1 } }, | ||
], | ||
}; | ||
|
@@ -459,7 +432,7 @@ const STATUS_FACET = { | |
* @namespace PRIORITY_FACET | ||
* @description Facet for service requests breakdown based on their priorities | ||
* | ||
* @version 0.1.0 | ||
* @version 0.2.0 | ||
* @since 0.1.0 | ||
*/ | ||
const PRIORITY_FACET = { | ||
|
@@ -474,22 +447,7 @@ const PRIORITY_FACET = { | |
pending: { $sum: '$pending' }, | ||
resolved: { $sum: '$resolved' }, | ||
unattended: { $sum: '$unattended' }, | ||
averageResolveTime: { $avg: '$ttr.milliseconds' }, | ||
averageAttendTime: { $avg: '$call.duration.milliseconds' }, | ||
}, | ||
}, | ||
{ | ||
$project: { | ||
_id: 1, | ||
name: 1, | ||
color: 1, | ||
weight: 1, | ||
count: 1, | ||
pending: 1, | ||
resolved: 1, | ||
unattended: 1, | ||
averageResolveTime: 1, | ||
averageAttendTime: 1, | ||
...METRIC_TIMES, | ||
}, | ||
}, | ||
{ | ||
|
@@ -502,7 +460,7 @@ const PRIORITY_FACET = { | |
* @namespace SERVICE_FACET | ||
* @description Facet for service requests breakdown based on their services(nature) | ||
* | ||
* @version 0.1.0 | ||
* @version 0.2.0 | ||
* @since 0.1.0 | ||
*/ | ||
const SERVICE_FACET = { | ||
|
@@ -517,22 +475,7 @@ const SERVICE_FACET = { | |
name: { $first: '$service.name' }, | ||
color: { $first: '$service.color' }, | ||
count: { $sum: 1 }, | ||
averageResolveTime: { $avg: '$ttr.milliseconds' }, | ||
averageAttendTime: { $avg: '$call.duration.milliseconds' }, | ||
}, | ||
}, | ||
{ | ||
$project: { | ||
_id: 1, | ||
pending: 1, | ||
resolved: 1, | ||
late: 1, | ||
unattended: 1, | ||
name: 1, | ||
color: 1, | ||
count: 1, | ||
averageResolveTime: 1, | ||
averageAttendTime: 1, | ||
...METRIC_TIMES, | ||
}, | ||
}, | ||
{ | ||
|
@@ -545,7 +488,7 @@ const SERVICE_FACET = { | |
* @namespace SERVICE_GROUP_FACET | ||
* @description Facet for service requests breakdown based on their service groups | ||
* | ||
* @version 0.1.0 | ||
* @version 0.2.0 | ||
* @since 0.1.0 | ||
*/ | ||
const SERVICE_GROUP_FACET = { | ||
|
@@ -560,22 +503,7 @@ const SERVICE_GROUP_FACET = { | |
name: { $first: '$group.name.en' }, | ||
color: { $first: '$group.color' }, | ||
count: { $sum: 1 }, | ||
averageResolveTime: { $avg: '$ttr.milliseconds' }, | ||
averageAttendTime: { $avg: '$call.duration.milliseconds' }, | ||
}, | ||
}, | ||
{ | ||
$project: { | ||
_id: 1, | ||
pending: 1, | ||
resolved: 1, | ||
late: 1, | ||
unattended: 1, | ||
name: 1, | ||
color: 1, | ||
count: 1, | ||
averageResolveTime: 1, | ||
averageAttendTime: 1, | ||
...METRIC_TIMES, | ||
}, | ||
}, | ||
{ | ||
|
@@ -588,7 +516,7 @@ const SERVICE_GROUP_FACET = { | |
* @namespace SERVICE_TYPE_FACET | ||
* @description Facet for service requests breakdown based on their service types | ||
* | ||
* @version 0.1.0 | ||
* @version 0.2.0 | ||
* @since 0.1.0 | ||
*/ | ||
const SERVICE_TYPE_FACET = { | ||
|
@@ -606,25 +534,12 @@ const SERVICE_TYPE_FACET = { | |
resolved: { $sum: '$resolved' }, | ||
unattended: { $sum: '$unattended' }, | ||
late: { $sum: '$late' }, | ||
averageResolveTime: { $avg: '$ttr.milliseconds' }, | ||
averageAttendTime: { $avg: '$call.duration.milliseconds' }, | ||
...METRIC_TIMES, | ||
}, | ||
}, | ||
{ | ||
$project: { | ||
_id: 1, | ||
name: 1, | ||
color: 1, | ||
code: 1, | ||
description: 1, | ||
abbreviation: 1, | ||
count: 1, | ||
pending: 1, | ||
resolved: 1, | ||
unattended: 1, | ||
late: 1, | ||
averageAttendTime: 1, | ||
averageResolveTime: 1, | ||
$sort: { | ||
count: -1, | ||
}, | ||
}, | ||
], | ||
|
@@ -666,7 +581,7 @@ const WORKSPACE_FACET = { | |
* @description Facet for service requests breakdown based on their reporting | ||
* methods | ||
* | ||
* @version 0.1.0 | ||
* @version 0.2.0 | ||
* @since 0.1.0 | ||
*/ | ||
const REPORTING_METHOD_FACET = { | ||
|
@@ -677,8 +592,6 @@ const REPORTING_METHOD_FACET = { | |
count: { $sum: 1 }, | ||
pending: { $sum: '$pending' }, | ||
resolved: { $sum: '$resolved' }, | ||
averageResolveTime: { $avg: '$ttr.milliseconds' }, | ||
averageAttendTime: { $avg: '$call.duration.milliseconds' }, | ||
}, | ||
}, | ||
{ | ||
|
@@ -687,8 +600,6 @@ const REPORTING_METHOD_FACET = { | |
count: 1, | ||
pending: 1, | ||
resolved: 1, | ||
averageResolveTime: 1, | ||
averageAttendTime: 1, | ||
}, | ||
}, | ||
{ $sort: { count: -1 } }, | ||
|
@@ -943,6 +854,7 @@ const normalizeMetricTimes = data => { | |
'approveTime', | ||
'resolveTime', | ||
'lateTime', | ||
'callTime', | ||
]; | ||
|
||
const times = map(keys, key => ({ | ||
|
@@ -978,6 +890,9 @@ const normalizeMetricTimes = data => { | |
'maximumConfirmTime', | ||
'minimumConfirmTime', | ||
'averageConfirmTime', | ||
'maximumCallTime', | ||
'minimumCallTime', | ||
'averageCallTime', | ||
]); | ||
|
||
return merge({}, strippedObject, ...times); | ||
|
@@ -1008,19 +923,19 @@ const prepareReportResponse = results => { | |
} | ||
|
||
if (data.jurisdictions) { | ||
data.jurisdictions = map(data.jurisdictions, normalizeObjectTimes); | ||
data.jurisdictions = map(data.jurisdictions, normalizeMetricTimes); | ||
} | ||
|
||
if (data.priorities) { | ||
data.priorities = map(data.priorities, normalizeObjectTimes); | ||
data.priorities = map(data.priorities, normalizeMetricTimes); | ||
} | ||
|
||
if (data.services) { | ||
data.services = map(data.services, normalizeObjectTimes); | ||
data.services = map(data.services, normalizeMetricTimes); | ||
} | ||
|
||
if (data.groups) { | ||
data.groups = map(data.groups, normalizeObjectTimes); | ||
data.groups = map(data.groups, normalizeMetricTimes); | ||
} | ||
|
||
if (data.types) { | ||
|
@@ -1151,7 +1066,7 @@ router.get(PATH_OPERATOR_PERFORMANCE, (request, response, next) => { | |
* @author Benson Maruchu <[email protected]> | ||
* @author lally elias <[email protected]> | ||
* @since 0.1.0 | ||
* @version 0.1.0 | ||
* @version 0.2.0 | ||
* @license MIT | ||
* @example | ||
* | ||
|
@@ -1178,4 +1093,4 @@ const info = pkg( | |
// extract api version | ||
const apiVersion = router.version; | ||
|
||
export { apiVersion, info, router }; | ||
export { router as analyticRouter, apiVersion, info }; |
Oops, something went wrong.