+15
-5
@@ -30,7 +30,7 @@ const stamp = (v: unknown) => {
|
||||
const s = text(v)
|
||||
return !Number.isNaN(Date.parse(s)) ? s : bad()
|
||||
}
|
||||
export const usageLabels: Record<string, string> = {
|
||||
export const usageLabels: Record<string, string> = Object.assign(Object.create(null), {
|
||||
国内工业: '国内工业',
|
||||
APAC: 'APAC',
|
||||
EMEA: 'EMEA',
|
||||
@@ -41,14 +41,24 @@ export const usageLabels: Record<string, string> = {
|
||||
identity_conflict: '身份冲突',
|
||||
no_identity: '身份信息缺失',
|
||||
directory_missing: '尚无完整通讯录',
|
||||
}
|
||||
})
|
||||
export function parseQAUsage(value: unknown): QAUsage {
|
||||
const v = obj(value)
|
||||
const v = obj(value),
|
||||
organization = parseQAOrganizationVersion(v.organization)
|
||||
const allowed = new Set([
|
||||
...(organization.region_names ?? []),
|
||||
'unassigned',
|
||||
'cross_region',
|
||||
'unmatched',
|
||||
'identity_conflict',
|
||||
'no_identity',
|
||||
'directory_missing',
|
||||
])
|
||||
if (!Array.isArray(v.rows)) return bad()
|
||||
const rows = v.rows.map((raw) => {
|
||||
const r = obj(raw)
|
||||
const key = text(r.key)
|
||||
if (!Object.hasOwn(usageLabels, key)) return bad()
|
||||
if (!allowed.has(key)) return bad()
|
||||
const row = {
|
||||
key,
|
||||
questions: count(r.questions),
|
||||
@@ -62,7 +72,7 @@ export function parseQAUsage(value: unknown): QAUsage {
|
||||
return row
|
||||
})
|
||||
const result = {
|
||||
organization: parseQAOrganizationVersion(v.organization),
|
||||
organization,
|
||||
as_of: stamp(v.as_of),
|
||||
start: stamp(v.start),
|
||||
end: stamp(v.end),
|
||||
|
||||
Reference in New Issue
Block a user