schedule renders 10x faster now. Caching disabled

This commit is contained in:
Ancor Gonzalez Sosa 2013-07-16 18:16:37 +02:00
parent 740a604c01
commit 08637503e5
2 changed files with 10 additions and 6 deletions

View file

@ -1,13 +1,12 @@
class ScheduleController < ApplicationController
layout "application"
caches_page :index
def index
@conference = Conference.find_all_by_short_title(params[:conference_id]).first
@conference = Conference.includes(:rooms, {:events => [:speakers, :track, :event_type]}).where("conferences.short_title" => params[:conference_id]).first
@rooms = @conference.rooms
@events = @conference.events
@dates = @conference.start_date..@conference.end_date
@rooms = @conference.rooms
end
end

View file

@ -28,6 +28,9 @@
<% conf_end = DateTime.parse("#{date} 19:00") %>
<% while conf_start < conf_end %>
<%-
start_hour = conf_start.hour
start_min = conf_start.min %>
<tr>
<td style="width:5%">
@ -35,7 +38,8 @@
</td>
<% @rooms.each do |room| %>
<% event = @events.find_all{|event|event.start_time and event.start_time.strftime("%Y-%m-%d %H:%M").eql? conf_start.strftime("%Y-%m-%d %H:%M") and event.room_id == room.id } %>
<% events_for_date = @events.find_all {|e| e.room_id == room.id && e.start_time && e.start_time.to_date == date } %>
<% event = events_for_date.find_all{|e| e.start_time.hour == start_hour && e.start_time.min == start_min } %>
<% if !event.empty? %>
<!-- There is an event, calculate the span and show it -->
<% span[room.id] = event[0].event_type.length / 15 %>
@ -44,8 +48,9 @@
class="event" role="button"
data-href="<%= url_for(conference_proposal_path(@conference.short_title, event[0].id)) %>">
<h5>
<%- speaker = event[0].speakers.first || event[0].submitter %>
<%= image_tag speaker.gravatar_url, :class => "img-circle pull-right", :alt => speaker.public_name, :title => speaker.public_name, :style => "padding:8px;" %>
<%- if speaker = event[0].speakers.first %>
<%= image_tag speaker.gravatar_url, :class => "img-circle pull-right", :alt => speaker.public_name, :title => speaker.public_name, :style => "padding:8px;" %>
<%- end %>
<span class="schedule-title">
<i class="icon-comment"></i>
<%= event[0].title %>