forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorganization-summary.js
More file actions
76 lines (70 loc) · 1.96 KB
/
organization-summary.js
File metadata and controls
76 lines (70 loc) · 1.96 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { GraphQLObjectType } from 'graphql'
import { categorizedSummaryType } from '../../summaries'
export const organizationSummaryType = new GraphQLObjectType({
name: 'OrganizationSummary',
description: 'Summaries based on domains that the organization has claimed.',
fields: () => ({
mail: {
type: categorizedSummaryType,
description:
'Summary based on mail scan results for a given organization.',
resolve: ({ mail }, _) => {
let percentPass, percentageFail
if (mail.total <= 0) {
percentPass = 0
percentageFail = 0
} else {
percentPass = Number(((mail.pass / mail.total) * 100).toFixed(1))
percentageFail = Number(((mail.fail / mail.total) * 100).toFixed(1))
}
const categories = [
{
name: 'pass',
count: mail.pass,
percentage: percentPass,
},
{
name: 'fail',
count: mail.fail,
percentage: percentageFail,
},
]
return {
categories,
total: mail.total,
}
},
},
web: {
type: categorizedSummaryType,
description:
'Summary based on web scan results for a given organization.',
resolve: ({ web }, _) => {
let percentPass, percentageFail
if (web.total <= 0) {
percentPass = 0
percentageFail = 0
} else {
percentPass = Number(((web.pass / web.total) * 100).toFixed(1))
percentageFail = Number(((web.fail / web.total) * 100).toFixed(1))
}
const categories = [
{
name: 'pass',
count: web.pass,
percentage: percentPass,
},
{
name: 'fail',
count: web.fail,
percentage: percentageFail,
},
]
return {
categories,
total: web.total,
}
},
},
}),
})