Files
werkregie/doc/prs/2026-10-14-PR#80-merge-lines.md
claude-code 74bd671ef0
werkator build succeeded after 00:50
werkator/deploy build succeeded after 00:25
The merge chart shows the changed lines per period and per pull request (#80)
Co-authored-by: claude-code <claude-code@javagil.de>
2026-10-14 20:18:55 +02:00

111 lines
4.9 KiB
Markdown

# PR#80: The Merge Chart Shows the Changed Lines per Period and per Pull Request
> **WARNING:** This document describes only the change applied in this PR.
> It may already be outdated once the next PR is merged.
> Historic PR documentation is not maintained along with new PRs; treat it as a snapshot.
## Related Links
- [werkregie PR#78](https://git.javagil.de/mi/werkregie/pulls/78): the merges per day, week and month of the configured authors.
## Problem
The merge chart counts the pull requests, but not their size.
The human wants to see how many lines a pull request changes on average,
e.g. 265 lines for `claude-code` in the 7 days up to 2026-10-14, with a median of 152.
Gitea has the data: the pull request that `MergeHistory` asks once for its base branch
names its `additions` and `deletions` as well.
## Non-Goals
- No split by file type, e.g. tests, documentation or lock files; the lines are those of the whole diff.
- No size classes, e.g. XS to XL.
- No JavaScript tests; werkregie has no framework for them yet, see Follow-up PRs.
## Specification
### Feature: the merge chart shows the changed lines
#### Scenario#80.01: the bars show the changed lines
&hellip; so that the human sees how much changes, not only how often.
- **Given** the merge chart of a Gitea with `mergeAuthors: [mi, claude-code]`,
and on one day a merge of `mi` with 30 added and 10 deleted lines and one of `claude-code` with 200 changed lines
- **When** the human selects "Zeilen"
- **Then** the bar of that day stacks 40 lines for `mi` on 200 for `claude-code`
##### Verified by
- [MergeHistoryTest "the merges of each configured author, oldest first, in seconds since the epoch, with their changed lines"](../../dashboard/src/test/kotlin/de/hoennig/werkregie/dashboard/sources/MergeHistoryTest.kt)
- [MergeHistoryTest "the changed lines are the added and the deleted ones, none where Gitea names none"](../../dashboard/src/test/kotlin/de/hoennig/werkregie/dashboard/sources/MergeHistoryTest.kt)
- [GiteaSourceFetchTest "without mergeAuthors the merges of the token's user count, with an empty list none"](../../dashboard/src/test/kotlin/de/hoennig/werkregie/dashboard/sources/GiteaSourceFetchTest.kt)
- manual check in the browser, see "Solution"
#### Scenario#80.02: the legend names the mean and the median per pull request
&hellip; so that a few large pull requests do not hide the usual size.
- **Given** the merge chart with 3 merges of `claude-code` in the shown periods, of 100, 150 and 1000 changed lines
- **When** the human opens the dashboard
- **Then** the legend shows for `claude-code` 3 merges, a mean of 417 and a median of 150 lines
##### Verified by
- manual check in the browser, see "Solution"
#### Scenario#80.03: the choice stays
&hellip; so that the human does not select it on each visit.
- **Given** the merge chart, showing the changed lines
- **When** the human opens the dashboard again
- **Then** the chart shows the changed lines
##### Verified by
- manual check in the browser, see "Solution"
#### Scenario#80.04: the lines do not load Gitea more
&hellip; so that the chart asks Gitea no more than before.
- **Given** the merge chart, which counts a merged pull request
- **When** the chart is updated 10 minutes later
- **Then** it shows the same lines for that pull request, without asking Gitea for it again
##### Verified by
- [MergeHistoryTest "each merged pull request is asked once for its base and its lines, a failed answer again"](../../dashboard/src/test/kotlin/de/hoennig/werkregie/dashboard/sources/MergeHistoryTest.kt)
## Solution
- `MergeHistory` keeps for each merged pull request its base check and its changed lines, `additions` plus `deletions`,
from the one answer it asks; `Merges.lines` holds them per author in the order of `mergedAt`.
A server older than 0.50.0 sends no `lines`; the page then counts 0 lines.
- The merge tile gets a second switch, "PRs | Zeilen"; with "Zeilen" each bar stacks the changed lines of its period.
The page keeps the choice, as it keeps the period.
- The legend names for each author the merges in the shown periods, and the mean and the median of their lines.
- Version 0.50.0.
### Manual Check
On 2026-10-14, a local dashboard with the configuration of the manual check of werkregie PR#78 showed for 30 days:
| Gitea | Author | Merges | Mean | Median |
|----------------------|----------------------|--------|------|--------|
| git.javagil.de | `mi` | 127 | 395 | 269 |
| git.javagil.de | `claude-code` | 249 | 301 | 174 |
| dev.hostsharing.net | `hsh-michaelhoennig` | 53 | 984 | 568 |
"Zeilen" stacked the lines per day, the tooltip of a bar named them per author, and the choice stayed after a reload.
## Open Questions
None.
## Follow-up PRs
- A test framework for the JavaScript of `index.html`, e.g. for `mergeSeries`; a new technology, it needs the consent of the human.