Skip to content

Instantly share code, notes, and snippets.

@bdarfler
Created May 23, 2018 17:07
Show Gist options
  • Save bdarfler/74a2cc9f8f70de31b5515d889085b182 to your computer and use it in GitHub Desktop.
Save bdarfler/74a2cc9f8f70de31b5515d889085b182 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
def recent_activities(limit)
c_stream = comments.order_by(:created_at).to_enum :find_each
i_stream = items.comments.order_by(:created_at).to_enum :find_each
b_stream = bids.order_by(:created_at).to_enum :find_each
ActivityFeedAggregator.new([c_stream, i_stream, b_stream]).next_activities(limit)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment