Extract grouping of boosts
This commit is contained in:
+2
-2
@@ -8,6 +8,6 @@ class Event < ApplicationRecord
|
||||
has_one :account, through: :creator
|
||||
|
||||
scope :chronologically, -> { order created_at: :asc, id: :desc }
|
||||
scope :unfurled, -> { where.not action: :boosted }
|
||||
scope :furled, -> { where action: :boosted }
|
||||
scope :non_boosts, -> { where.not action: :boosted }
|
||||
scope :boosts, -> { where action: :boosted }
|
||||
end
|
||||
|
||||
@@ -3,5 +3,9 @@ class EventSummary < ApplicationRecord
|
||||
|
||||
attr_accessor :bubble
|
||||
|
||||
has_many :events, -> { chronologically }, dependent: :delete_all, inverse_of: :summary
|
||||
has_many :events, -> { chronologically }, dependent: :delete_all, inverse_of: :summary do
|
||||
def grouped_boosts
|
||||
boosts.group_by(&:creator)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="event-summary flex-inline flex-wrap align-start fill-white border-radius center position-relative" data-controller="event-summary">
|
||||
<%# Template Dependency: events/actions/* %>
|
||||
<%= render event_summary.events.unfurled, cache: true %>
|
||||
<% event_summary.events.furled.group_by(&:creator).each do |creator, events| %>
|
||||
<%= render event_summary.events.non_boosts, cache: true %>
|
||||
<% event_summary.events.grouped_boosts.each do |creator, events| %>
|
||||
<%= render partial: "events/actions/boosted", locals: { creator: creator, count: events.size } %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user