dont show inefficiencies breakdown when there are none

This commit is contained in:
Alex Goodman 2018-10-14 11:04:11 -04:00
parent 18b405db72
commit 4e7e9b64e3
No known key found for this signature in database
GPG Key ID: 05328C611D8A520E

View File

@ -73,15 +73,20 @@ func (view *DetailsView) Render() error {
var wastedSpace int64 var wastedSpace int64
template := "%5s %12s %-s\n" template := "%5s %12s %-s\n"
var trueInefficiencies int
inefficiencyReport := fmt.Sprintf(Formatting.Header(template), "Count", "Total Space", "Path") inefficiencyReport := fmt.Sprintf(Formatting.Header(template), "Count", "Total Space", "Path")
for idx := len(view.inefficiencies)-1; idx > 0; idx-- { for idx := len(view.inefficiencies)-1; idx > 0; idx-- {
data := view.inefficiencies[idx] data := view.inefficiencies[idx]
if data.CumulativeSize == 0 { if data.CumulativeSize == 0 {
continue continue
} }
trueInefficiencies++
wastedSpace += data.CumulativeSize wastedSpace += data.CumulativeSize
inefficiencyReport += fmt.Sprintf(template, strconv.Itoa(len(data.Nodes)), humanize.Bytes(uint64(data.CumulativeSize)), data.Path) inefficiencyReport += fmt.Sprintf(template, strconv.Itoa(len(data.Nodes)), humanize.Bytes(uint64(data.CumulativeSize)), data.Path)
} }
if trueInefficiencies == 0 {
inefficiencyReport = ""
}
effStr := fmt.Sprintf("\n%s %d %%", Formatting.Header("Image efficiency score:"), int(100.0*view.efficiency)) effStr := fmt.Sprintf("\n%s %d %%", Formatting.Header("Image efficiency score:"), int(100.0*view.efficiency))
spaceStr := fmt.Sprintf("%s %s\n", Formatting.Header("Potential wasted space:"), humanize.Bytes(uint64(wastedSpace))) spaceStr := fmt.Sprintf("%s %s\n", Formatting.Header("Potential wasted space:"), humanize.Bytes(uint64(wastedSpace)))