# Contributor Heatmap

- **Command:** `lore contributors [--since <date>]`
- **Confidence:** 88%
- **Tier:** 2
- **Status:** proposed
- **Effort:** medium — multiple aggregation queries

## What

Rank team members by activity across configurable time windows (7d, 30d, 90d). Shows
issues authored, MRs authored, MRs merged, review comments made, discussions
participated in.

## Why

Team leads constantly ask "who's been active?" or "who's contributing to reviews?"
This answers it from local data without GitLab Premium analytics. Also useful for
identifying team members who may be overloaded or disengaged.

## Data Required

All exists today:
- `issues` (author_username, created_at)
- `merge_requests` (author_username, created_at, merged_at)
- `notes` (author_username, created_at, note_type, is_system)
- `discussions` (for participation counting)

## Implementation Sketch

```sql
-- Combined activity per author
WITH activity AS (
    SELECT author_username, 'issue_authored' as activity_type, created_at
    FROM issues WHERE created_at >= ?1
    UNION ALL
    SELECT author_username, 'mr_authored', created_at
    FROM merge_requests WHERE created_at >= ?1
    UNION ALL
    SELECT author_username, 'mr_merged', merged_at
    FROM merge_requests WHERE merged_at >= ?1 AND state = 'merged'
    UNION ALL
    SELECT author_username, 'review_comment', created_at
    FROM notes WHERE created_at >= ?1 AND note_type = 'DiffNote' AND is_system = 0
    UNION ALL
    SELECT author_username, 'discussion_comment', created_at
    FROM notes WHERE created_at >= ?1 AND note_type != 'DiffNote' AND is_system = 0
)
SELECT
    author_username,
    COUNT(*) FILTER (WHERE activity_type = 'issue_authored') as issues,
    COUNT(*) FILTER (WHERE activity_type = 'mr_authored') as mrs_authored,
    COUNT(*) FILTER (WHERE activity_type = 'mr_merged') as mrs_merged,
    COUNT(*) FILTER (WHERE activity_type = 'review_comment') as reviews,
    COUNT(*) FILTER (WHERE activity_type = 'discussion_comment') as comments,
    COUNT(*) as total
FROM activity
GROUP BY author_username
ORDER BY total DESC;
```

Note: SQLite doesn't support FILTER — use SUM(CASE WHEN ... THEN 1 ELSE 0 END).

## Human Output

```
Contributors (last 30 days)

  Username    Issues  MRs  Merged  Reviews  Comments  Total
  alice          3     8      7      23        12       53
  bob            1     5      4      31         8       49
  charlie        5     3      2       4        15       29
  dave           0     1      0       2         3        6
```

## Downsides

- Could be used for surveillance; frame as team health, not individual tracking
- Activity volume != productivity (one thoughtful review > ten "LGTM"s)
- Doesn't capture work done outside GitLab

## Extensions

- `lore contributors --project group/backend` — scoped to project
- `lore contributors --type reviews` — focus on review activity only
- Trend comparison: `--compare 30d,90d` shows velocity changes
