Skip to content

リファクタリング#7

Merged
max747 merged 19 commits intomainfrom
feature/refactor
Feb 19, 2026
Merged

リファクタリング#7
max747 merged 19 commits intomainfrom
feature/refactor

Conversation

@max747
Copy link
Copy Markdown
Member

@max747 max747 commented Feb 19, 2026

No description provided.

max747 and others added 16 commits February 19, 2026 20:49
aggregate.ts と summaryUtils.ts に重複定義されていたアイテム分類用の
正規表現(イベントアイテム・ポイント・QP)を constants.ts に一元化した。
変数名を RE_EVENT_ITEM / RE_POINT / RE_QP に統一。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
aggregate.ts・ReportTable.tsx・QuestView.tsx の4箇所で重複していた
`new Set(exclusions.map((e) => e.reportId))` を
createExcludedIdSet() として aggregate.ts に export し、
各利用箇所からその関数を呼び出すよう統一した。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
QuestView・ReporterSummary・EventItemSummaryPage の3箇所で
重複していたローディング/エラー表示を LoadingError コンポーネントに抽出した。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ReportTable と ReporterSummary のインラインだった toggleSort 実装を
hooks/useSortState.ts に移動した。
- useSortState: null 許容、asc→desc→null サイクル(ReportTable 向け)
- useFixedSortState: null 不可、desc↔asc トグル(ReporterSummary 向け)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ReportTable の excludedIds/exclusionMap/outlierMap/statsMap/sorted と
ReporterSummary の rawRows/rows を useMemo でメモ化した。
hooks ルールに合わせて全 useMemo を early return より前に配置。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SummaryTable と EventItemSummaryView で重複定義されていた
MAX_EVENT_BONUS = 12 を constants.ts に移動した。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ReportTable.tsx に埋め込まれていた formatNote・formatItemHeader と
関連定数(RE_FGOSCCNT・RE_MODIFIER)を formatters.tsx(.ts → .tsx リネーム)に移動した。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
reportTableUtils と reporterSummaryUtils で重複定義されていた
SortDir = "asc" | "desc" を types.ts に一元化した。
useSortState.ts も SortDir を import して型注釈を統一。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ReporterSummary.tsx のインライン Set<string> トグルロジックを
hooks/useToggleSet.ts に移動した。
展開ボタンの onClick が toggleExpanded(r.reporter) の1行になりすっきりした。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
報告者名列と X ID 列で同じ「xId が有効ならリンク、そうでなければテキスト」
という条件分岐を XIdLink コンポーネントに集約した。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
リスト順変更時の React の差分検出を正確にするため、
`key={i}` を `key={d.reportId}` に修正する。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Number("90+") が NaN になりソート順が不定になる問題を修正。
parseLevel() で parseInt + "+" サフィックスに 0.5 を加算し、
90+ > 90 の順序を保証する。テストも意図を明確化した。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
data・exclusions が変わらない限り aggregate(), calcOutlierStats(),
excludedIds, totalRuns, validCount, sortedItemNames を再計算しないように
useMemo でキャッシュする。hooks を早期 return より前に移動した。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
コンポーネント unmount 時に進行中の fetch をキャンセルできるよう、
QuestView / ReporterSummary / EventItemSummaryPage / AppLayout の
useEffect に AbortController を追加する。
api.ts の各関数も signal?: AbortSignal を受け取れるよう拡張した。
AbortError はエラーとして扱わずスキップする。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Viewer 側の「リファクタリング」として、共通定数・型・表示/状態管理ロジックの集約、並びに fetch の中断対応(AbortController)を広く適用して保守性を上げる変更です。

Changes:

  • 正規表現や定数(イベントアイテム/ポイント/QP、MAX_EVENT_BONUS)を constants.ts に集約し、利用箇所を置換
  • ソート/展開状態の共通フック追加(useSortState, useFixedSortState, useToggleSet)とテーブル周辺の整理
  • fetch API を AbortSignal 対応にし、各ページ/コンポーネントで中断処理と共通ローディング/エラー表示を導入
  • 90+ のようなクエストレベル文字列を考慮した比較ロジックを追加(routeUtils)

Reviewed changes

Copilot reviewed 27 out of 28 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
viewer/src/types.ts SortDir を共通型として追加
viewer/src/summaryUtils.ts アイテム分類/抽出の正規表現を constants に寄せる
viewer/src/routeUtils.ts 90+ を考慮したレベル比較ロジックを追加
viewer/src/routeUtils.test.ts 90+ の期待挙動をテストで固定
viewer/src/reporterSummaryUtils.ts SortDirtypes 側に集約して参照
viewer/src/reporterSummaryUtils.test.ts import 順の調整
viewer/src/reportTableUtils.ts SortDirtypes 側に集約して参照
viewer/src/reportTableUtils.test.ts import 順の調整
viewer/src/pages/EventItemSummaryPage.tsx AbortSignal 対応・LoadingError 導入・取得処理整理
viewer/src/main.tsx import 並び順調整
viewer/src/hooks/useToggleSet.ts Set のトグル状態管理フック追加
viewer/src/hooks/useSortState.ts null 許容/固定ソートの共通フック追加
viewer/src/formatters.tsx 既存フォーマッタに加え、ノート/アイテム見出しの表示整形を追加
viewer/src/formatters.ts formatters.tsx へ移行(旧ファイル削除)
viewer/src/constants.ts MAX_EVENT_BONUS と共通正規表現を新規追加
viewer/src/components/SummaryTable.tsx MAX_EVENT_BONUS を定数化して参照
viewer/src/components/ReporterSummary.tsx fetch 中断対応・共通フック導入・メモ化・リンク処理整理
viewer/src/components/ReportTable.tsx 共有フォーマッタ/フック/メモ化を導入して整理
viewer/src/components/QuestView.tsx fetch 中断対応・LoadingError 導入・集計処理をメモ化
viewer/src/components/LoadingError.tsx ローディング/エラー表示の共通コンポーネント追加
viewer/src/components/EventItemSummaryView.tsx MAX_EVENT_BONUS を定数化して参照
viewer/src/api.ts fetch 関数に AbortSignal を追加
viewer/src/aggregate.ts exclusions の Set 化処理を関数化し、定数/正規表現参照を統一
package.json Biome を v2 系へ更新
package-lock.json Biome v2 への追従更新
biome.json Biome v2 の schema / 設定キーに更新
admin/src/auth/AuthProvider.tsx import 並び順調整

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

max747 and others added 3 commits February 19, 2026 23:26
依存変数変更で前回 fetch を abort しつつ新リクエストを開始した際に、
前回の finally が後から実行されて loading: true を上書きする競合を防ぐ。
controller.signal.aborted を確認して abort 済みなら state 更新をスキップする。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
EventItemSummaryPage と AppLayout のクエストソートで Number(a.level) を
使っていたため "90+" が NaN になりソート順が不定だった。
parseLevel を routeUtils からエクスポートして共用し、両箇所を置き換えた。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
renderToStaticMarkup を使って HTML 文字列で検証する方式で、
URL のリンク化・修飾子の改行分割・該当なし時のパススルーを確認する。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@max747 max747 merged commit bd9b250 into main Feb 19, 2026
1 check passed
@max747 max747 removed their assignment Feb 19, 2026
@max747 max747 deleted the feature/refactor branch February 23, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants