Skip to content

Commit

Permalink
Add Mel::Progress::Report.new(Indexable(String)) overload
Browse files Browse the repository at this point in the history
  • Loading branch information
akadusei committed Aug 26, 2023
1 parent 418326a commit bdcbdb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased] -

### Added
- Add `Mel::Progress::Report.new(Indexable(String))` overload

## [0.11.0] - 2023-08-26

### Changed
Expand Down
7 changes: 5 additions & 2 deletions src/mel/progress/report.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ struct Mel::Progress
new(hash["id"], hash["description"], hash["value"])
end

def self.new(row : Indexable(String))
new row.each_slice(2).to_h
end

def started? : Bool
moving?
end
Expand Down Expand Up @@ -43,8 +47,7 @@ struct Mel::Progress
rows = redis ? Query.get(ids, redis) : Query.get(ids)

reports = rows.each.map(&.as(Array).map &.as(String)).compact_map do |row|
next unless row.size == 6
new row.each_slice(2).to_h
new(row) if row.size == 6
end.to_a

reports unless reports.empty?
Expand Down

0 comments on commit bdcbdb1

Please sign in to comment.