fix: use all work reviews for first pass metric

This commit is contained in:
江林铖 2026-08-31 15:12:38 +08:00
parent ba0b198eb8
commit 69750d32b4
3 changed files with 16 additions and 26 deletions

View File

@ -120,7 +120,7 @@ function FirstPassProjectList({ metric, query, firstPassPage }: Required<Pick<Co
<div>
<h2 id="first-pass-list-title" className="text-xl font-bold tracking-[-0.02em] sm:text-2xl">所有作品明细</h2>
<p className="mt-1 text-sm leading-6 text-slate-600">
展示当前部门范围内全部已上传且包含 V1 的作品;每个作品只取 V1 审核结果,评审中、首轮未通过和待核对状态均会列出。
展示作品过稿后台全部已上传且包含 V1 的作品;每个作品只取 V1 审核结果,评审中、首轮未通过和待核对状态均会列出。
</p>
</div>
<a

View File

@ -71,7 +71,7 @@ describe('department dashboard first-pass review details', () => {
}])
})
test('summary keeps the full department V1 population while search narrows only detail rows', async () => {
test('summary keeps the full brand-center V1 population while search narrows only detail rows', async () => {
const result = await getFirstPassReviewProjects(session, {
page: 2,
pageSize: 10,
@ -82,24 +82,14 @@ describe('department dashboard first-pass review details', () => {
by: ['status'],
where: {
version: 1,
project: {
is: {
submitterEmployee: {
is: expect.objectContaining({ OR: expect.any(Array) }),
},
},
},
project: { is: {} },
},
_count: { _all: true },
})
expect(prisma.workReviewProject.count).toHaveBeenCalledWith({
where: {
AND: [
{
submitterEmployee: {
is: expect.objectContaining({ OR: expect.any(Array) }),
},
},
{},
{ status: 'approved' },
],
},
@ -108,11 +98,7 @@ describe('department dashboard first-pass review details', () => {
where: expect.objectContaining({
AND: expect.arrayContaining([
expect.objectContaining({ AND: expect.arrayContaining([
expect.objectContaining({
submitterEmployee: {
is: expect.objectContaining({ OR: expect.any(Array) }),
},
}),
{},
{ versions: { some: { version: 1 } } },
]) }),
expect.objectContaining({ OR: expect.any(Array) }),

View File

@ -655,27 +655,31 @@ async function getFirstPassReviewSummaryForProjectWhere(
}
/**
* 部门看板“首轮通过”的真实统计口径。
* 品牌中心看板“首轮通过”的真实统计口径。
*
* 分子仅包含 V1 状态为 approved 的作品,分母是当前账号明确部门路径范围内
* 当前状态为 approved 的全部作品。全部 V1 上传数只用于明细总量展示。
* 分子仅包含 V1 状态为 approved 的作品,分母是作品过稿后台当前状态为
* approved 的全部作品。全部 V1 上传数只用于明细总量展示。
*/
export async function getFirstPassReviewSummary(
session: Session | null,
): Promise<FirstPassReviewSummary> {
const ctx = await getContext(session)
return getFirstPassReviewSummaryForProjectWhere(getDepartmentDashboardProjectWhere(ctx))
// 首轮通过是品牌中心全量作品指标,不按登录人的部门路径缩小分母。
// getContext 仍负责会话校验和作品过稿通知 worker 的启动,但其部门范围
// 只适用于“进行中项目”等部门视图,不适用于这个全量作品指标。
await getContext(session)
return getFirstPassReviewSummaryForProjectWhere({})
}
export async function getFirstPassReviewProjects(
session: Session | null,
params?: { page?: number; pageSize?: number; query?: string },
): Promise<FirstPassReviewProjectPage> {
const ctx = await getContext(session)
// 明细与卡片使用同一套品牌中心全量作品口径;搜索和分页只缩小明细列表。
await getContext(session)
const page = Math.max(1, Number(params?.page || 1) || 1)
const pageSize = Math.min(50, Math.max(1, Number(params?.pageSize || 20) || 20))
const query = clean(params?.query)
const scopeWhere = getDepartmentDashboardProjectWhere(ctx)
const scopeWhere = {}
const scopeFilters: any[] = [
scopeWhere,
{ versions: { some: { version: 1 } } },