5a4d2a72c8
I'm not sure if this was inadvertent or an artifact of an earlier design but I'm fairly certain we want a more comprehensive list of events here. Especially comments, for example. We should show all the comments that happen in a particular hour on the timeline. There may be places were we need to dial back but for now I'm going to lift the constraint and see how it feels.
43 lines
1.2 KiB
Ruby
43 lines
1.2 KiB
Ruby
class EventsController < ApplicationController
|
|
include BucketFilterable
|
|
before_action :set_activity_day
|
|
|
|
def index
|
|
update_bucket_filter
|
|
@buckets = Current.user.buckets.alphabetically
|
|
@events = events_by_hour_and_column
|
|
@next_day = latest_event_before_today&.created_at
|
|
end
|
|
|
|
private
|
|
def events_by_hour_and_column
|
|
user_events.where(created_at: @activity_day.all_day).
|
|
group_by { |event| [ event.created_at.hour, helpers.event_column(event) ] }.
|
|
map { |hour_col, events| [ hour_col, events ] }
|
|
end
|
|
|
|
def latest_event_before_today
|
|
user_events.where(created_at: ...@activity_day.beginning_of_day).chronologically.last
|
|
end
|
|
|
|
def user_events
|
|
Event.where(bubble: user_bubbles, creator: Current.account.users.without_system)
|
|
end
|
|
|
|
def user_bubbles
|
|
Current.user.accessible_bubbles
|
|
.published_or_drafted_by(Current.user)
|
|
.where(bucket_id: bucket_filter)
|
|
end
|
|
|
|
def set_activity_day
|
|
@activity_day = if params[:day].present?
|
|
Time.zone.parse(params[:day])
|
|
else
|
|
Time.zone.now
|
|
end
|
|
rescue ArgumentError
|
|
raise ActionController::RoutingError
|
|
end
|
|
end
|