Only show unique bubble entries in each cluster

This commit is contained in:
Kevin McConnell
2025-01-27 15:18:01 +00:00
parent 0816c60255
commit 3f3b5f3a61
+10 -4
View File
@@ -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