forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb-summary.js
More file actions
34 lines (29 loc) · 947 Bytes
/
web-summary.js
File metadata and controls
34 lines (29 loc) · 947 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
34
import { t } from '@lingui/macro'
import { categorizedSummaryType } from '../objects'
export const webSummary = {
type: categorizedSummaryType,
description: 'Web summary computed values, used to build summary cards.',
resolve: async (_, __, { i18n, loaders: { loadChartSummaryByKey } }) => {
const summary = await loadChartSummaryByKey.load('web')
if (typeof summary === 'undefined') {
console.warn(`User could not retrieve web summary.`)
throw new Error(i18n._(t`Unable to load web 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,
}
},
}