# pipeline_stage_duration

Elixir library and Mix task. Give it a stage-history CSV (one row per deal per stage, with the date the deal entered and left the stage) and it prints how many days deals spend in each stage: average, median and longest, slowest stage first. A row with no exit date is still in the stage and is measured up to the as-of date.

Part of the [OneGTMLab](https://www.onegtmlab.dev) free GTM tools. Background on the idea: [middle of funnel](https://www.onegtmlab.dev/glossary/middle-of-funnel).

## Install

```
{:pipeline_stage_duration, "~> 1.0"}   # in mix.exs deps
```

## Use

CSV columns: deal, stage, entered, exited (YYYY-MM-DD, exited empty for an open stage).

```
$ mix pipeline.stage_duration sample.csv --as-of 2026-11-28
stage            deals     avg  median  longest
proposal             3    24.7    22.0       32
negotiation          1    23.0    23.0       23
discovery            4    13.0    10.5       27
```

## Test

```
mix test
```

Offline, no network calls, no dependencies beyond the language runtime. MIT licensed.
