From f18529b26ba0f496b396e96f988128594f786343 Mon Sep 17 00:00:00 2001 From: Matt Duszynski Date: Mon, 25 Jul 2022 20:40:17 -0500 Subject: [PATCH 1/2] Fix sample building for TS.MADD with multiple series --- CHANGELOG.md | 1 + lib/redis/time_series.rb | 2 +- spec/redis/time_series_spec.rb | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d012dcb..c4e0cd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## Unreleased +* Fix sample building for TS.MADD with multiple series (#76) ## 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 From e8f5ca516e3b2fed38c424bc3eeddd9c43ddd431 Mon Sep 17 00:00:00 2001 From: Matt Duszynski Date: Mon, 25 Jul 2022 20:40:58 -0500 Subject: [PATCH 2/2] Changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4e0cd5..671fba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Changelog ## Unreleased -* Fix sample building for TS.MADD with multiple series (#76) +* Fix sample building for TS.MADD with multiple series (#77) ## 0.7.1 * Handle ActiveSupport::TimeWithZone objects (#75)