Juggernaut.View.History (Juggernaut v0.4.0)

Copy Markdown View Source

The run history (mix juggernaut.history, design notes §3, §7.2): one row per recorded run, newest first, then trends over the runs shown, oldest to newest, as sparklines of the score, the mutant count, the wall time and the results reused.

It reads the records of Juggernaut.Store.History.read/1 (string-keyed maps). A run's wall time is its finished_at minus its started_at, as recorded. Reused results are shown with the run time recorded for them, labelled as recorded. Lines the history reader skipped are listed with their reason, and a field of a readable line that is missing or not of the expected type is shown as "-" (and null in trends): one odd line never stops the listing. Nothing is cut silently: when the limit hides older runs the output says how many and how to see them.

The JSON document is {"format": 1, "kind": "history", "total", "shown", "more", "next", "runs", "trends", "skipped"}; each run is its history record (keys sorted) plus wall_ms, and each trend lists one value per shown run, oldest first.

Summary

Functions

The history in format (:human or :json).

The records matching filters (lane, since date), newest first, at most limit; with the number matched and the number left out.

A sparkline of values (numbers, nil for a gap shown as a space), scaled from the smallest to the largest; equal values are drawn at mid height.

A run's recorded wall time in milliseconds (finished_at - started_at), or nil.

Types

filters()

@type filters() :: [limit: pos_integer(), lane: atom() | nil, since: Date.t() | nil]

history()

@type history() :: %{
  records: [map()],
  skipped: [%{line: pos_integer(), reason: String.t()}]
}

Functions

render(format, map, filters)

@spec render(:human | :json, history(), keyword()) :: iodata()

The history in format (:human or :json).

select(records, filters)

@spec select([map()], keyword()) :: %{
  runs: [map()],
  total: non_neg_integer(),
  more: non_neg_integer()
}

The records matching filters (lane, since date), newest first, at most limit; with the number matched and the number left out.

sparkline(values)

@spec sparkline([number() | nil]) :: String.t()

A sparkline of values (numbers, nil for a gap shown as a space), scaled from the smallest to the largest; equal values are drawn at mid height.

wall_ms(record)

@spec wall_ms(map()) :: non_neg_integer() | nil

A run's recorded wall time in milliseconds (finished_at - started_at), or nil.