feat(qa-ops): 支持自定义区域与分级部门批量归属
build / build (push) Successful in 1m8s

This commit is contained in:
姚章浩
2026-10-18 21:50:29 +08:00
parent 8835a473dd
commit 76671e0784
33 changed files with 865 additions and 100 deletions
+15 -5
View File
@@ -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),