Only show unique bubble entries in each cluster
This commit is contained in:
@@ -2,15 +2,21 @@ class EventsController < ApplicationController
|
||||
before_action :set_activity_day
|
||||
|
||||
def index
|
||||
@events = user_events.where(created_at: @activity_day.all_day).
|
||||
group_by { |event| [ event.created_at.hour, helpers.event_column(event) ] }
|
||||
|
||||
@events = unique_events_by_hour_and_column
|
||||
@next_day = @activity_day.yesterday.strftime("%Y-%m-%d")
|
||||
end
|
||||
|
||||
private
|
||||
def unique_events_by_hour_and_column
|
||||
events_by_hour_and_column.map { |hour_col, events| [ hour_col, events.uniq(&:bubble_id) ] }
|
||||
end
|
||||
|
||||
def events_by_hour_and_column
|
||||
user_events.group_by { |event| [ event.created_at.hour, helpers.event_column(event) ] }
|
||||
end
|
||||
|
||||
def user_events
|
||||
Event.where(bubble: user_bubbles)
|
||||
Event.where(bubble: user_bubbles).where(created_at: @activity_day.all_day)
|
||||
end
|
||||
|
||||
def user_bubbles
|
||||
|
||||
Reference in New Issue
Block a user