[feat]Implement FullCalendarFormatter#event_schedules_to_resources; Add tests

This commit is contained in:
Jimmy 2021-04-26 10:34:14 +08:00 committed by CactusPuppy
parent abe2ea9bb3
commit 4b83ae8be7
No known key found for this signature in database
GPG key ID: 4B33B0A3E15E2C82
2 changed files with 46 additions and 8 deletions

View file

@ -3,14 +3,28 @@ class FullCalendarFormatter
rooms.map { |room| room_to_resource(room) }.to_json
end
def self.event_schedules_to_resources(event_schedules); end
def self.event_schedules_to_resources(event_schedules)
event_schedules.map { |event_schedule| event_schedule_to_resource(event_schedule) }.to_json
end
private_class_method
class << self
private
def self.room_to_resource(room)
{
id: room.guid,
title: room.name
}
def room_to_resource(room)
{
id: room.guid,
title: room.name
}
end
def event_schedule_to_resource(event_schedule)
{
id: event_schedule.event.guid,
title: event_schedule.event.title,
start: event_schedule.start_time,
end: event_schedule.end_time,
source: event_schedule.room.guid
}
end
end
end