Skip to content

Commit

Permalink
Add current month past events to full calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
mattlindsey committed Feb 13, 2023
1 parent 1c0e4db commit d16b76d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def show

def index
@projects = Project.active
@events = Event.upcoming_events(specified_project)
respond_to do |format|
format.html { @events }
format.json { @events }
format.html { @events = Event.upcoming_events(specified_project) }
format.json { @events = Event.upcoming_events(specified_project)
@scrums = EventInstance.this_month_until_now }
end
end

Expand Down
7 changes: 7 additions & 0 deletions app/models/event_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ def channels_for_event
event.slack_channel_codes
end

def self.this_month_until_now
beginning_of_month = Date.current.at_beginning_of_month
EventInstance
.where('created_at BETWEEN ? AND ?', beginning_of_month, DateTime.current)
.order(created_at: :desc)
end

private

def manually_updated_event_not_finished?
Expand Down
10 changes: 7 additions & 3 deletions app/views/events/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# frozen_string_literal: true

date_format = '%Y-%m-%dT%H:%M:%S'
json.array! @scrums do |scrum|
json.title scrum.title
json.start scrum.created_at.strftime(date_format)
end_time = scrum.created_at + 1800
json.end end_time.strftime(date_format)
end
json.array! @events do |event|
# date_format = event.all_day_event? ? '%Y-%m-%d' : '%Y-%m-%dT%H:%M:%S'
date_format = '%Y-%m-%dT%H:%M:%S'
json.title event[:event].name
json.start event[:time].strftime(date_format)
end_time = event[:time] + event[:event].duration * 60
Expand Down

0 comments on commit d16b76d

Please sign in to comment.