{{define "history"}}

#### Number of times unplugged: {{.Count}}

{{range $key, $value := .UnplugSummaries}}

Summary {{$key}}

{{.LevelDrop}} pct drop @ {{printf "%.2f" .LevelDropPerHour}} %/hr over {{.Duration}}
({{.SummaryStart}} - {{.SummaryEnd}})
{{end}}

{{range $key, $value := .UnplugSummaries}}

### Summary {{$key}}

Device State Summary:

ID | Name | Count / Hr | Seconds / Hr | Total Num | Total Duration | Max Duration
--- | --- | --- | --- | --- | --- | ---
{{range $id, $stat := $value.SystemStats}}
{{$id}} | {{$stat.Name}} | {{printf "%.2f" $stat.NumRate}} | {{printf "%.2f" $stat.DurationRate}} | {{$stat.Num}} | {{$stat.TotalDuration}} | {{$stat.MaxDuration}}
{{end}}

{{range $brstat := $value.BreakdownStats}} {{if $brstat.Stats }}
{{$brstat.Metric}}:
{{if or (eq $brstat.Metric "FirstWakelockAfterSuspend") (eq $brstat.Metric "DetailedWakelockSummary")}}

ID | Name | Count / Hr | Total Num
--- | --- | --- | ---
{{range $id, $stat := $brstat.Stats}}
{{$id}} | {{$stat.Name}} | {{printf "%.2f" $stat.NumRate}} | {{$stat.Num}}
{{end}}

{{else}}

ID | Name | Count / Hr | Seconds / Hr | Total Num | Total Duration | Max Duration
--- | --- | --- | --- | --- | --- | ---
{{range $id, $stat := $brstat.Stats}}
{{$id}} | {{$stat.Name}} | {{printf "%.2f" $stat.NumRate}} | {{printf "%.2f" $stat.DurationRate}} | {{$stat.Num}} | {{$stat.TotalDuration}} | {{$stat.MaxDuration}}
{{end}}

{{end}} {{end}} {{end}}
{{end}} {{end}}