forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail-summary.js
More file actions
33 lines (29 loc) · 952 Bytes
/
mail-summary.js
File metadata and controls
33 lines (29 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { categorizedSummaryType } from '../objects'
import { t } from '@lingui/macro'
export const mailSummary = {
type: categorizedSummaryType,
description: 'Email summary computed values, used to build summary cards.',
resolve: async (_, __, { i18n, loaders: { loadChartSummaryByKey } }) => {
const summary = await loadChartSummaryByKey.load('mail')
if (typeof summary === 'undefined') {
console.warn(`User could not retrieve mail summary.`)
throw new Error(i18n._(t`Unable to load mail summary. Please try again.`))
}
const categories = [
{
name: 'pass',
count: summary.pass,
percentage: Number(((summary.pass / summary.total) * 100).toFixed(1)),
},
{
name: 'fail',
count: summary.fail,
percentage: Number(((summary.fail / summary.total) * 100).toFixed(1)),
},
]
return {
categories,
total: summary.total,
}
},
}