From 4311de353c16c8e7a77363a98fcbbb04abab5a87 Mon Sep 17 00:00:00 2001 From: max747 Date: Sat, 9 May 2026 20:07:28 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=E5=A0=B1=E5=91=8A=E8=80=85=E3=82=B5?= =?UTF-8?q?=E3=83=9E=E3=83=AA:=20=E5=A0=B1=E5=91=8A=E8=80=85=20=E3=81=AE?= =?UTF-8?q?=E3=83=AA=E3=83=B3=E3=82=AF=E5=85=88=E3=81=8C=E9=96=93=E9=81=95?= =?UTF-8?q?=E3=81=A3=E3=81=A6=E3=81=84=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lambda/aggregator/handler.py | 1 + viewer/src/aggregate.test.ts | 1 + viewer/src/components/ReporterSummary.tsx | 20 ++++++++++---------- viewer/src/reportTableUtils.test.ts | 1 + viewer/src/reporterSummaryUtils.test.ts | 8 +++++--- viewer/src/reporterSummaryUtils.ts | 2 ++ viewer/src/types.ts | 1 + 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lambda/aggregator/handler.py b/lambda/aggregator/handler.py index c4cef1e..72dcb5b 100644 --- a/lambda/aggregator/handler.py +++ b/lambda/aggregator/handler.py @@ -193,6 +193,7 @@ def process_quest(event_id: str, quest: dict, event_items: set[str]) -> None: { "id": report.get("id", report.get("report_id", "")), "reporter": report.get("reporter", ""), + "reporterId": report.get("reporter_id", ""), "reporterName": report.get("reporter_name", ""), "runcount": report.get("runcount", 0), "timestamp": report.get("timestamp", ""), diff --git a/viewer/src/aggregate.test.ts b/viewer/src/aggregate.test.ts index 6981bf3..7e4b843 100644 --- a/viewer/src/aggregate.test.ts +++ b/viewer/src/aggregate.test.ts @@ -6,6 +6,7 @@ function makeReport(id: string, runcount: number, items: Record{children}; + if (!id || id === "anonymous") return <>{children}; return ( {children} @@ -172,17 +172,17 @@ export function ReporterSummary({ eventId, quests, exclusions }: Props) { {i + 1} - {r.reporter} - + - + {r.xId} - + {r.reportCount.toLocaleString()} {r.totalRuns.toLocaleString()} diff --git a/viewer/src/reportTableUtils.test.ts b/viewer/src/reportTableUtils.test.ts index 068fab3..b38d355 100644 --- a/viewer/src/reportTableUtils.test.ts +++ b/viewer/src/reportTableUtils.test.ts @@ -7,6 +7,7 @@ function makeReport(overrides: Partial = {}): Report { return { id: "r1", reporter: "user1", + reporterId: "", reporterName: "User 1", runcount: 100, timestamp: "2026-01-01T00:00:00Z", diff --git a/viewer/src/reporterSummaryUtils.test.ts b/viewer/src/reporterSummaryUtils.test.ts index 54e2121..14dd255 100644 --- a/viewer/src/reporterSummaryUtils.test.ts +++ b/viewer/src/reporterSummaryUtils.test.ts @@ -11,6 +11,7 @@ function makeQuestData( reporter: string; reporterName: string; runcount: number; + reporterId?: string; }>, ): QuestData { return { @@ -18,6 +19,7 @@ function makeQuestData( lastUpdated: "2026-01-01T00:00:00Z", reports: reports.map((r) => ({ ...r, + reporterId: r.reporterId ?? "", timestamp: "2026-01-01T00:00:00Z", note: "", items: {}, @@ -122,9 +124,9 @@ describe("aggregateReporters", () => { describe("sortRows", () => { const rows: ReporterRow[] = [ - { reporter: "A", xId: "a", reportCount: 3, totalRuns: 100, details: [] }, - { reporter: "B", xId: "b", reportCount: 1, totalRuns: 300, details: [] }, - { reporter: "C", xId: "c", reportCount: 2, totalRuns: 200, details: [] }, + { reporter: "A", reporterId: "", xId: "a", reportCount: 3, totalRuns: 100, details: [] }, + { reporter: "B", reporterId: "", xId: "b", reportCount: 1, totalRuns: 300, details: [] }, + { reporter: "C", reporterId: "", xId: "c", reportCount: 2, totalRuns: 200, details: [] }, ]; test("totalRuns 昇順", () => { diff --git a/viewer/src/reporterSummaryUtils.ts b/viewer/src/reporterSummaryUtils.ts index 16c85b7..6223f73 100644 --- a/viewer/src/reporterSummaryUtils.ts +++ b/viewer/src/reporterSummaryUtils.ts @@ -11,6 +11,7 @@ export interface ReportDetail { export interface ReporterRow { reporter: string; + reporterId: string; xId: string; reportCount: number; totalRuns: number; @@ -46,6 +47,7 @@ export function aggregateReporters( const name = getReporterName(r); const entry = map.get(name) ?? { reporter: name, + reporterId: r.reporterId || "", xId: r.reporter || "", reportCount: 0, totalRuns: 0, diff --git a/viewer/src/types.ts b/viewer/src/types.ts index 83a0f91..cbd5197 100644 --- a/viewer/src/types.ts +++ b/viewer/src/types.ts @@ -26,6 +26,7 @@ export interface EventsResponse { export interface Report { id: string; reporter: string; + reporterId: string; reporterName: string; runcount: number; timestamp: string; From c417bb985c8aa1fb5a70dfb799b5d844cfee2b3d Mon Sep 17 00:00:00 2001 From: max747 Date: Sat, 9 May 2026 20:25:22 +0900 Subject: [PATCH 2/5] =?UTF-8?q?aggregateReporters:=20=E5=BE=8C=E7=B6=9A?= =?UTF-8?q?=E5=A0=B1=E5=91=8A=E3=81=AE=20reporterId/xId=20=E3=81=A7?= =?UTF-8?q?=E7=A9=BA=E6=AC=84=E3=82=92=E8=A3=9C=E5=AE=8C=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 最初の報告に reporterId が空でも、後の報告に有効な値があれば更新する。 xId も同様に補完する。 Co-Authored-By: Claude Sonnet 4.6 --- viewer/src/reporterSummaryUtils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/viewer/src/reporterSummaryUtils.ts b/viewer/src/reporterSummaryUtils.ts index 6223f73..01adb79 100644 --- a/viewer/src/reporterSummaryUtils.ts +++ b/viewer/src/reporterSummaryUtils.ts @@ -53,6 +53,8 @@ export function aggregateReporters( totalRuns: 0, details: [], }; + if (!entry.reporterId && r.reporterId) entry.reporterId = r.reporterId; + if (!entry.xId && r.reporter) entry.xId = r.reporter; entry.reportCount += 1; entry.totalRuns += r.runcount; entry.details.push({ From f75224cd67c56232189bf42e427063a51535044e Mon Sep 17 00:00:00 2001 From: max747 Date: Sat, 9 May 2026 20:25:46 +0900 Subject: [PATCH 3/5] =?UTF-8?q?test:=20aggregateReporters=20=E3=81=AE=20re?= =?UTF-8?q?porterId=20=E4=BC=9D=E6=92=AD=E3=82=92=E3=83=86=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - reporterId が ReporterRow に正しく伝わることを検証 - 最初の報告が空 reporterId でも後続報告の値で補完されることを検証 Co-Authored-By: Claude Sonnet 4.6 --- viewer/src/reporterSummaryUtils.test.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/viewer/src/reporterSummaryUtils.test.ts b/viewer/src/reporterSummaryUtils.test.ts index 14dd255..f6fcd8b 100644 --- a/viewer/src/reporterSummaryUtils.test.ts +++ b/viewer/src/reporterSummaryUtils.test.ts @@ -120,6 +120,27 @@ describe("aggregateReporters", () => { expect(rows[0].details[0].runcount).toBe(50); expect(rows[0].details[0].reportId).toBe("r1"); }); + + test("reporterId を ReporterRow に伝える", () => { + const data = [ + makeQuestData("q1", "Quest 1", [ + { id: "r1", reporter: "user1", reporterName: "User 1", runcount: 100, reporterId: "owner-abc" }, + ]), + ]; + const rows = aggregateReporters(data, {}); + expect(rows[0].reporterId).toBe("owner-abc"); + }); + + test("最初の報告の reporterId が空でも後続報告の値で補完する", () => { + const data = [ + makeQuestData("q1", "Quest 1", [ + { id: "r1", reporter: "user1", reporterName: "User 1", runcount: 100, reporterId: "" }, + { id: "r2", reporter: "user1", reporterName: "User 1", runcount: 50, reporterId: "owner-abc" }, + ]), + ]; + const rows = aggregateReporters(data, {}); + expect(rows[0].reporterId).toBe("owner-abc"); + }); }); describe("sortRows", () => { From 9c8ecc90dd4df8834fec7274ebe674b2cf8ef5c7 Mon Sep 17 00:00:00 2001 From: max747 Date: Sat, 9 May 2026 20:28:37 +0900 Subject: [PATCH 4/5] fix import path --- lambda/aggregator/test_handler.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lambda/aggregator/test_handler.py b/lambda/aggregator/test_handler.py index 141d790..b72edd2 100644 --- a/lambda/aggregator/test_handler.py +++ b/lambda/aggregator/test_handler.py @@ -2,7 +2,7 @@ import os import sys -from unittest.mock import MagicMock +from unittest.mock import MagicMock, patch # boto3 はテスト環境に存在しないため、インポート前にモック化する os.environ.setdefault("S3_BUCKET_NAME", "test-bucket") @@ -10,8 +10,6 @@ sys.modules["botocore"] = MagicMock() sys.modules["botocore.exceptions"] = MagicMock() -from unittest.mock import patch - from handler import detect_event_items, is_raw_count_report, process_quest, transform_report # noqa: E402 From 21b490e271e680cd5126b06e7063bf1e260424a2 Mon Sep 17 00:00:00 2001 From: max747 Date: Sat, 9 May 2026 20:29:18 +0900 Subject: [PATCH 5/5] fix lint error --- viewer/src/reporterSummaryUtils.test.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/viewer/src/reporterSummaryUtils.test.ts b/viewer/src/reporterSummaryUtils.test.ts index f6fcd8b..bd385e1 100644 --- a/viewer/src/reporterSummaryUtils.test.ts +++ b/viewer/src/reporterSummaryUtils.test.ts @@ -124,7 +124,13 @@ describe("aggregateReporters", () => { test("reporterId を ReporterRow に伝える", () => { const data = [ makeQuestData("q1", "Quest 1", [ - { id: "r1", reporter: "user1", reporterName: "User 1", runcount: 100, reporterId: "owner-abc" }, + { + id: "r1", + reporter: "user1", + reporterName: "User 1", + runcount: 100, + reporterId: "owner-abc", + }, ]), ]; const rows = aggregateReporters(data, {}); @@ -135,7 +141,13 @@ describe("aggregateReporters", () => { const data = [ makeQuestData("q1", "Quest 1", [ { id: "r1", reporter: "user1", reporterName: "User 1", runcount: 100, reporterId: "" }, - { id: "r2", reporter: "user1", reporterName: "User 1", runcount: 50, reporterId: "owner-abc" }, + { + id: "r2", + reporter: "user1", + reporterName: "User 1", + runcount: 50, + reporterId: "owner-abc", + }, ]), ]; const rows = aggregateReporters(data, {});