Skip to content

excludedUsersをcompanyGithubUsers.typeに統合する #146

@coji

Description

@coji

背景

現在、bot/非人間ユーザーの除外が2つの仕組みで行われている:

  1. organizationSettings.excludedUsers — comma-separated テキスト。batch 処理でレビュー/ディスカッションのアクターを除外し、サイクルタイム計算(pickup time, review time)に影響
  2. companyGithubUsers.typefeat: add type column to GitHub Users for bot filtering #145 で追加。PR一覧の表示フィルタ(type = 'Bot' を除外)

CopilotDEFAULT_EXCLUDED_USERS としてハードコードされている。

対応方針

companyGithubUsers.type に統合する:

  1. batch の filterActors()excludedUsers リストの代わりに companyGithubUsers.type = 'Bot' を参照
  2. DEFAULT_EXCLUDED_USERS (Copilot) も type = 'Bot' で管理
  3. organizationSettings.excludedUsers カラムと設定 UI を削除
  4. 既存の excludedUsers 設定値をマイグレーションで companyGithubUsers.type に反映

実装計画

Phase 1: excludedUsers → companyGithubUsers.type 統合

Step 1: tenant DBマイグレーション

  • 既存の excludedUsers の値を companyGithubUserstype='Bot' として挿入/更新
  • copilottype='Bot' として確実に登録
  • organization_settings から excluded_users カラムを DROP
  • db/tenant.sql から excluded_users カラム定義を削除

Step 2: 型再生成

  • pnpm db:apply && pnpm db:generatetenant-type.ts から excludedUsers が消える

Step 3: batch処理の変更

  • batch/db/queries.ts: getTenantData() から excludedUsers を削除。新関数 getBotLogins(organizationId): Promise<Set<string>> を追加
  • batch/github/pullrequest.ts: DEFAULT_EXCLUDED_USERS 定数を削除。BuildConfig.excludedUsersBuildConfig.botLogins: Set<string>filterActors()Set.has() に変更
  • batch/github/analyze-repos.ts: organizationSetting の型から excludedUsers を削除、新パラメータ botLogins: Set<string> を追加
  • batch/usecases/analyze-and-upsert.ts: OrganizationForAnalyze から excludedUsers を削除、getBotLogins() で取得して渡す

Step 4: 設定UIの削除

  • +forms/organization-settings.tsx: excludedUsersフィールドを削除
  • +schema.ts: excludedUsers フィールドを削除
  • +functions/mutations.server.ts: updateOrganizationSetting から excludedUsers を削除
  • index.tsx: submission.valueとmutation呼び出しから excludedUsers を削除

Step 5: Copilot自動Bot登録

  • batch/db/mutations.tsupsertCompanyGithubUsers()copilot (case-insensitive) を自動的に type='Bot' で登録

Step 6: テスト更新

  • batch/github/__tests__/buildPullRequests-filter.test.ts: config.excludedUsersconfig.botLogins: new Set<string>()

Phase 2: type変更時の自動再計算トリガー(durable execution 導入後)

companyGithubUsers.type を UI で変更した際、サイクルタイムの再計算(upsert)を自動的にバックグラウンド実行する。

  • 前提: durable execution 基盤(ジョブキュー)が導入済みであること
  • 実装: GitHub Users 設定画面で type を変更 → ジョブキューに upsert ジョブを enqueue → バックグラウンドで全PRを再計算
  • 理由: type 変更のたびに手動で upsert を実行する必要がなくなり、UX が向上する

関連

注意点

  • excludedUsers は PR 作者ではなくレビュアー/コメント者の除外に使われている
  • 統合後は batch の buildPullRequests で tenant DB から companyGithubUsers を参照する必要がある
  • Phase 2 は durable execution 基盤の導入が前提。それまでは type 変更後に手動で batch upsert を実行する必要がある

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions