diff --git a/lib/timeline_lookup.rb b/lib/timeline_lookup.rb index 4d4c3eac8f..1c62d879f5 100644 --- a/lib/timeline_lookup.rb +++ b/lib/timeline_lookup.rb @@ -11,10 +11,10 @@ module TimelineLookup tuples.each_with_index do |t, idx| next unless (idx % every) === 0 - _, post_number, days_ago = t + days_ago = t[2] if (days_ago != last_days_ago) - result << [post_number, days_ago] + result << [idx+1, days_ago] last_days_ago = days_ago end diff --git a/spec/components/timeline_lookup_spec.rb b/spec/components/timeline_lookup_spec.rb index 8cb5edc5b2..3e1a2ef02a 100644 --- a/spec/components/timeline_lookup_spec.rb +++ b/spec/components/timeline_lookup_spec.rb @@ -16,6 +16,11 @@ describe TimelineLookup do expect(result).to eq([[1, 10], [3, 8]]) end + it "respects holes in the post numbers" do + result = TimelineLookup.build([[111, 1, 10], [222, 12, 10], [333, 30, 8]]) + expect(result).to eq([[1, 10], [3, 8]]) + end + it "respects a `max_values` setting" do input = (1..100).map {|i| [1000+i, i, 100-i] }