Skip to content

Commit

Permalink
Make GoogleCalendarEvent class
Browse files Browse the repository at this point in the history
  • Loading branch information
kjtbw committed Jun 6, 2017
1 parent 1ab7452 commit 71f1e3c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def list
month = "#{date.year}-#{date.month}"
events = kvs.load(month)
events.each do |event|
collection << kvs.format_event(event)
collection << GoogleCalendarEvent.to_fullcalendar(event)
end
end
render json: collection
Expand Down
15 changes: 15 additions & 0 deletions app/models/google_calendar_event.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class GoogleCalendarEvent < Event
def self.to_fullcalendar(e)
event = {}
event["id"] = e["id"]
event["title"] = e["summary"]
event["start"] = e["start"]["dateTime"] || e["start"]["date"]
event["end"] = e["end"]["dateTime"] || e["end"]["date"]
if e["start"]["date"] then
event["allDay"] = true
else
event["allDay"] = false
end
return event
end
end
14 changes: 0 additions & 14 deletions app/models/redis_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,5 @@ def store(key,value)
def delete(key)
@redis.del(key)
end

def format_event(e)
event = {}
event["id"] = e["id"]
event["title"] = e["summary"]
event["start"] = e["start"]["dateTime"] || e["start"]["date"]
event["end"] = e["end"]["dateTime"] || e["end"]["date"]
if e["start"]["date"] then
event["allDay"] = true
else
event["allDay"] = false
end
return event
end# end format event
end# end RedisStore
end# end DataStore

0 comments on commit 71f1e3c

Please sign in to comment.