Skip to content

Commit

Permalink
Total processed images count showing added (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarampampam authored Jun 19, 2020
1 parent ad5483c commit 0eea0ac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver].

## v2.1.0

### Added

- Total processed images count showing [#12]

[#12]:https://github.com/tarampampam/tinifier/issues/12

## v2.0.0

### Changed
Expand Down
12 changes: 8 additions & 4 deletions cmd/compress/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ func (cmd *Command) readResults(results chan result, total int, wg *sync.WaitGro
totalOriginalBytes uint64
totalCompressedBytes,
totalSavedBytes int64
totalProcessed int64
)

defer func() {
Expand Down Expand Up @@ -233,6 +234,7 @@ func (cmd *Command) readResults(results chan result, total int, wg *sync.WaitGro
totalOriginalBytes += result.originalSizeBytes
totalSavedBytes += diffBytes
totalCompressedBytes += int64(result.compressedSizeBytes)
totalProcessed++

// append a row in a table
table.Append([]string{
Expand Down Expand Up @@ -261,8 +263,10 @@ func (cmd *Command) readResults(results chan result, total int, wg *sync.WaitGro
}

// append summary stats into table
table.SetFooter([]string{"", "", "Total saved", fmt.Sprintf("%s (-%0.2f%%)",
humanize.IBytes(uint64(totalSavedBytes)),
calcPercentageDiff(float64(totalCompressedBytes), float64(totalOriginalBytes)),
)})
table.SetFooter([]string{"", "", fmt.Sprintf("Total saved (%d files)", totalProcessed),
fmt.Sprintf("%s (-%0.2f%%)",
humanize.IBytes(uint64(totalSavedBytes)),
calcPercentageDiff(float64(totalCompressedBytes), float64(totalOriginalBytes)),
),
})
}

0 comments on commit 0eea0ac

Please sign in to comment.