Skip to content

Commit

Permalink
Fix error
Browse files Browse the repository at this point in the history
```
Invalid Int32: "report description or id here" (ArgumentError)
```

The order of items retrieved from redis is not guaranteed, but the
previous implementation assumed it was.
  • Loading branch information
akadusei committed Aug 26, 2023
1 parent 7082f65 commit f991745
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Set default `.batch_size` to `-100`
- Increase default `.poll_interval` to 15 seconds

### Fixed
- Fix `Invalid Int32` error when tracking progress

## [0.10.0] - 2023-06-01

### Changed
Expand Down
14 changes: 6 additions & 8 deletions src/mel/progress/report.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ struct Mel::Progress
@value = value.to_i
end

def self.new(hash : Hash)
new(hash["id"], hash["description"], hash["value"])
end

def started? : Bool
moving?
end
Expand All @@ -36,17 +40,11 @@ struct Mel::Progress

def self.find(ids : Indexable, redis = nil) : Array(Mel::Progress::Report)?
return if ids.empty?

rows = redis ? Query.get(ids, redis) : Query.get(ids)

reports = rows.each.map(&.as(Array).map &.as(String)).compact_map do |row|
row[1]?.try do |description|
row[3]?.try do |id|
row[5]?.try do |value|
new(id, description, value)
end
end
end
next unless row.size == 6
new row.each_slice(2).to_h
end.to_a

reports unless reports.empty?
Expand Down

0 comments on commit f991745

Please sign in to comment.