Skip to content

Commit c157e96

Browse files
A duplicate review filter pages only the pairs it matches (#1495)
Signed-off-by: Maya Kid <BinjunYann@gmail.com> Co-authored-by: WaylandYang <145302500+WaylandYang@users.noreply.github.com>
1 parent e160214 commit c157e96

2 files changed

Lines changed: 48 additions & 4 deletions

File tree

‎web/src/pages/Review.tsx‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ const FACT_PAGE = 10;
5757
const MERGE_PAGE = 10;
5858
const CONFLICT_PAGE = 8;
5959

60+
export function DuplicateReviewPager({
61+
totals,
62+
types,
63+
page,
64+
onPage,
65+
}: {
66+
totals: Record<ReviewTypeFilter, number>;
67+
types: ReviewTypeFilter;
68+
page: number;
69+
onPage: (page: number) => void;
70+
}) {
71+
return <Pager total={totals[types]} pageSize={DUP_PAGE} page={page} onPage={onPage} />;
72+
}
73+
6074
const ym = (iso: string | null) => (iso ? iso.slice(0, 7) : null);
6175

6276
/** `code` 或 `code|detail`。查不到就原样显示——存量行里还是旧的英文散文 */
@@ -1634,6 +1648,11 @@ export function Review() {
16341648
decisions: history.data?.total ?? 0,
16351649
agent: c?.agent ?? 0,
16361650
};
1651+
const duplicateTotals: Record<ReviewTypeFilter, number> = {
1652+
any: counts.duplicates,
1653+
same: c?.duplicates_same_type ?? 0,
1654+
conflict: c?.duplicates_type_conflict ?? 0,
1655+
};
16371656
// 当前这一档的一页。**服务端已经切好了**,这里只按档收窄类型——
16381657
// 收窄错了会在渲染时露馅,而不是悄悄显示空列表
16391658
const rows = review.data?.queue === queueSel ? (review.data.items ?? []) : [];
@@ -1881,16 +1900,16 @@ export function Review() {
18811900
setPage(0);
18821901
}}
18831902
options={[
1884-
{ value: "any", label: S.review.typesAny, count: counts.duplicates },
1903+
{ value: "any", label: S.review.typesAny, count: duplicateTotals.any },
18851904
{
18861905
value: "same",
18871906
label: S.review.typesSame,
1888-
count: c?.duplicates_same_type ?? 0,
1907+
count: duplicateTotals.same,
18891908
},
18901909
{
18911910
value: "conflict",
18921911
label: S.review.typesConflict,
1893-
count: c?.duplicates_type_conflict ?? 0,
1912+
count: duplicateTotals.conflict,
18941913
},
18951914
]}
18961915
/>
@@ -2294,7 +2313,9 @@ export function Review() {
22942313
))}
22952314

22962315
{/* 单一分页:queue/merges 走客户端切片,decisions 服务端分页;总览没有页 */}
2297-
{active !== "decisions" && active !== "overview" && (
2316+
{active === "duplicates" ? (
2317+
<DuplicateReviewPager totals={duplicateTotals} types={types} page={page} onPage={setPage} />
2318+
) : active !== "decisions" && active !== "overview" && (
22982319
<Pager
22992320
total={active === "agent" ? (c?.agent_rows ?? 0) : counts[active]}
23002321
pageSize={PAGE_SIZE[active]}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { createElement } from "react";
2+
import { renderToStaticMarkup } from "react-dom/server";
3+
import { describe, expect, it } from "vitest";
4+
import type { ReviewTypeFilter } from "../api";
5+
import { S } from "../i18n";
6+
import { DuplicateReviewPager } from "./Review";
7+
8+
describe("duplicate review pagination", () => {
9+
// Only one pair matches Same type; one untyped pair belongs only to All.
10+
const totals = { any: 9, same: 1, conflict: 7 };
11+
const render = (types: ReviewTypeFilter, page = 0) =>
12+
renderToStaticMarkup(createElement(DuplicateReviewPager, { totals, types, page, onPage: () => {} }));
13+
14+
it("does not offer another page for the only matching pair", () => {
15+
expect(render("same")).toBe("");
16+
});
17+
18+
it("counts all pairs only in All and reaches the final filtered pair", () => {
19+
expect(render("any", 1)).toContain(S.library.pageOf(7, 9, 9));
20+
expect(render("conflict")).toContain(S.library.pageOf(1, 6, 7));
21+
expect(render("conflict", 1)).toContain(S.library.pageOf(7, 7, 7));
22+
});
23+
});

0 commit comments

Comments
 (0)