home cache
This commit is contained in:
parent
63cd19c15c
commit
47e6c3eedd
|
@ -22,6 +22,33 @@ module WelcomeHelper
|
||||||
include CoursesHelper
|
include CoursesHelper
|
||||||
include ProjectsHelper
|
include ProjectsHelper
|
||||||
|
|
||||||
|
def get_timestamp(obj)
|
||||||
|
if obj.respond_to? :updated_on
|
||||||
|
:updated_on
|
||||||
|
elsif obj.respond_to? :updated_at
|
||||||
|
:updated_at
|
||||||
|
elsif obj.respond_to? :created_on
|
||||||
|
:created_on
|
||||||
|
elsif obj.respond_to? :created_at
|
||||||
|
:created_at
|
||||||
|
else
|
||||||
|
Time.now.to_i.to_s.to_sym
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def cache_key_for_project(obj)
|
||||||
|
timestamp = get_timestamp(obj)
|
||||||
|
"welcome_index_project_ul_#{obj.class}_li_#{obj.id}_#{obj.__send__ timestamp}"
|
||||||
|
end
|
||||||
|
def cache_key_for_event(obj)
|
||||||
|
timestamp = get_timestamp(obj)
|
||||||
|
"welcome_index_event_ul_#{obj.class}_li_#{obj.id}_#{obj.__send__ timestamp}"
|
||||||
|
end
|
||||||
|
def cache_key_for_topic(obj)
|
||||||
|
timestamp = get_timestamp(obj)
|
||||||
|
"welcome_index_topic_ul_#{obj.class}_li_#{obj.id}_#{obj.__send__ timestamp}"
|
||||||
|
end
|
||||||
|
|
||||||
def welcome_join_in_course(project, user)
|
def welcome_join_in_course(project, user)
|
||||||
if(user.logged? &&
|
if(user.logged? &&
|
||||||
!(course_endTime_timeout? project) &&
|
!(course_endTime_timeout? project) &&
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
<ul class="d-p-projectlist">
|
<ul class="d-p-projectlist">
|
||||||
<% projects = find_miracle_project(10, 3) %>
|
<% projects = find_miracle_project(10, 3) %>
|
||||||
<% projects.map do |project| %>
|
<% projects.map do |project| %>
|
||||||
<% cache "welcome_index_hotProject_ul_project_#{project.id}_li" do %>
|
<% cache cache_key_for_project(project) do %>
|
||||||
<li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'>
|
<li style="position:relative;height:6em;" class='<%= cycle("odd", "even") %>'>
|
||||||
<div style="float: left;">
|
<div style="float: left;">
|
||||||
<%= image_tag(get_project_avatar(project), :class => "avatar-4") %>
|
<%= image_tag(get_project_avatar(project), :class => "avatar-4") %>
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
<div class="user-message-box-list" style="margin-top: 10px;">
|
<div class="user-message-box-list" style="margin-top: 10px;">
|
||||||
<%activities = find_all_activities%>
|
<%activities = find_all_activities%>
|
||||||
<% activities.each do |event| %>
|
<% activities.each do |event| %>
|
||||||
<% cache "welcome_index_userActivity_ul_event_#{event.class}_#{event.id}_li" do %>
|
<% cache cache_key_for_event(event) do %>
|
||||||
<li style="display: block;height:60px; padding-bottom: 4px;">
|
<li style="display: block;height:60px; padding-bottom: 4px;">
|
||||||
<div class="inner-right" style="float: left; height: 100%; ">
|
<div class="inner-right" style="float: left; height: 100%; ">
|
||||||
<%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %>
|
<%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %>
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
<div class="welcome-box-list-new memo_activity">
|
<div class="welcome-box-list-new memo_activity">
|
||||||
<% topics = find_new_forum_topics(7) %>
|
<% topics = find_new_forum_topics(7) %>
|
||||||
<% topics.includes(:forum, :last_reply, :author).each do |topic|%>
|
<% topics.includes(:forum, :last_reply, :author).each do |topic|%>
|
||||||
<% cache "welcome_index_memosActivity_ul_topic_#{topic.id}_li" do %>
|
<% cache cache_key_for_topic(topic) do %>
|
||||||
<li class="message-brief-intro">
|
<li class="message-brief-intro">
|
||||||
<div class='memo_title text_nowrap'>
|
<div class='memo_title text_nowrap'>
|
||||||
<%= link_to '['+topic.forum.name + ']',forum_path(topic.forum),:class => 'memo_Bar_title' %><%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url,title: topic.subject %>
|
<%= link_to '['+topic.forum.name + ']',forum_path(topic.forum),:class => 'memo_Bar_title' %><%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url,title: topic.subject %>
|
||||||
|
|
Loading…
Reference in New Issue