diff --git a/CHANGELOG.md b/CHANGELOG.md index d012dcb..671fba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## Unreleased +* Fix sample building for TS.MADD with multiple series (#77) ## 0.7.1 * Handle ActiveSupport::TimeWithZone objects (#75) diff --git a/lib/redis/time_series.rb b/lib/redis/time_series.rb index 61105ad..8a2e241 100644 --- a/lib/redis/time_series.rb +++ b/lib/redis/time_series.rb @@ -108,7 +108,7 @@ def destroy(key) # def madd(data) data.reduce([]) do |memo, (key, value)| - memo << parse_madd_values(key, value) + memo += parse_madd_values(key, value) memo end.then do |args| cmd('TS.MADD', args).each_with_index.map do |result, idx| diff --git a/spec/redis/time_series_spec.rb b/spec/redis/time_series_spec.rb index 7b0bd65..e0731fa 100644 --- a/spec/redis/time_series_spec.rb +++ b/spec/redis/time_series_spec.rb @@ -188,6 +188,14 @@ def msec(ts) end.to issue_command "TS.MADD foo #{ts_msec} 1 foo #{ts_msec + 1} 2 foo #{ts_msec + 2} 3 "\ "bar #{ts_msec} 4 bar #{ts_msec + 1} 5 bar #{ts_msec + 2} 6 bar #{ts_msec + 3} 7" end + + it 'correctly returns samples' do + described_class.create(:foo) + expect(described_class.madd(foo: { 123 => 1, 456 => 2 })).to all( + be_a(Redis::TimeSeries::Sample) + ) + described_class.destroy(:foo) + end end end