/** Weekly aggregate row — one per ISO-Monday-anchored bucket. */
export interface WeeklyMetric {
  /** Monday 00:00 (wall time, in the configured timezone). ISO date: "YYYY-MM-DD". */
  weekStart: string;
  /** Following Monday (exclusive). ISO date: "YYYY-MM-DD". */
  weekEnd: string;
  /** All PRs merged that week across the managed repos (repos.json). Includes every author — humans AND bots. */
  prsMergedTotal: number;
  /** Subset of prsMergedTotal whose PR author login matches the configured bot user (`hu-agent[bot]`). */
  prsMergedBot: number;
  /** Subset of prsMergedTotal authored by *other* bots (login ends in `[bot]` but isn't hu-agent, e.g. github-actions[bot], humand-react-bot[bot]). Subtract from total + bot to get human authors. */
  prsMergedOtherBots: number;
}

/** Per-repo rollup of merged PRs across the whole analytics window. */
export interface RepoAdoptionRow {
  repo: string;
  prsMergedTotal: number;
  prsMergedBot: number;
  prsMergedOtherBots: number;
}

/** Per-squad rollup derived from ticket-key prefixes in PR branch names. */
export interface SquadAdoptionRow {
  /** Squad project key (SQDP, SQRN, …) or "unmapped" when no ticket key in the branch. */
  squad: string;
  /** Tribe from SQUAD_TRIBE_MAP; empty for unmapped. */
  tribe: string;
  prsMergedTotal: number;
  prsMergedBot: number;
  prsMergedOtherBots: number;
}

export interface AnalyticsReport {
  meta: {
    /** First-week Monday of the analytics window (ISO date). */
    startDate: string;
    /** ISO timestamp of generation. */
    generatedAt: string;
    /** Timezone used to anchor week buckets. */
    timezone: string;
    /** GitHub login counted as "the bot". */
    botLogin: string;
    /** Number of repos scanned. */
    reposScanned: number;
  };
  weekly: WeeklyMetric[];
  byRepo: RepoAdoptionRow[];
  bySquad: SquadAdoptionRow[];
}
