个人主页缓存增加

yuanke_cache
yuanke 9 years ago
parent 0eeb4ed439
commit efc2874b6c

@ -1724,7 +1724,7 @@ class UsersController < ApplicationController
end
end
@user_activities = UserActivity.where("#{sql}").order('updated_at desc').limit(10).offset(@page * 10)
@user_activities = UserActivity.where("#{sql}").order('updated_at desc').limit(5).offset(@page * 5)
@type = params[:type]
respond_to do |format|
format.js

@ -59,7 +59,7 @@
</div>
<% end %>
<div class="sy_class_info fl ml15">
<% cache [:course_righthead,@course.id.to_s] do%>
<% cache [:course_righthead,@course.id.to_s+"-"+@course.updated_at.to_i.to_s] do%>
<div class="sy_class_titbox">
<h3 class="fl sy_class_title">
<%= link_to @course.syllabus.title, syllabus_path(@course.syllabus_id), :class =>'c_dark', :target => '_blank'%>

@ -1,7 +1,10 @@
<% courses.each do |course|%>
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %>
<% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %>
<% wechat_count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %>
<% cache [:homepage_course_info,course.id.to_s+"-"+is_teacher.to_s+"-"+(User.current == user).to_s+"-"+(User.current.member_of_course?(course)).to_s+"-"+count.to_s+"-"+wechat_count.to_s+course.updated_at.to_i.to_s] do%>
<li>
<span class="user_icons_class"></span>
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %>
<p href="javascript:void(0);" id="show_course_<%= course.id %>" class="course_list_menu pr" >
<% title = "<span class='course-name'>#{course.syllabus.title}</span>".html_safe %>
<%= link_to title, syllabus_path(course.syllabus_id), :target => '_blank', :class => 'hidden', :style => "max-width:91px; display:inline-block;"%>
@ -16,9 +19,6 @@
</p>
<%#= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course),
:id => "show_course_#{course.id}", :class => 'course_list_menu hidden', :target => '_blank', :title => (course.is_public? ? "公开班级:":"私有班级:")+course.name+""+current_time_and_term(course)+""%>
<% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %>
<% wechat_count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %>
<div class="user_navmore_box">
<ul class="<%#= count > 0 ? 'shild shildP':'subNavArrow'%>">
<li class="user_navmore_icons">
@ -83,7 +83,7 @@
<% end %>
</li>
<% end %>
<% if User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %>
<% if is_teacher %>
<li>
<%= link_to course.is_public == 0 ? "设为公开" : "设为私有", {:controller => 'courses', :action => 'private_or_public', :id => course,:user_page => true},
:id => "set_course_public_#{course.id.to_s}",:remote=>true, :class => 'user_navmore_li',:confirm=>"您确定要设置为"+(course.is_public == 0 ? "公开" : "私有")+"吗"%>
@ -95,6 +95,7 @@
</ul>
</div>
</li>
<% end %>
<% end %>
<% if all_count > (page.to_i+1) * 10%>

@ -1,9 +1,15 @@
<% projects.each do |project|%>
<% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count %>
<% wechat_count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count %>
<% is_logged = User.current.logged? %>
<% is_admin = User.current.admin? %>
<% current_user_isuser = User.current == @user %>
<% can_setting = User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, project) %>
<% is_manager = is_project_manager?(User.current,project) %>
<% cache [:homepage_project_info,project.id.to_s+"-"+is_logged.to_s+"-"+is_admin.to_s+"-"+current_user_isuser.to_s+"-"+can_setting.to_s+"-"+count.to_s+"-"+wechat_count.to_s+"-"+is_manager.to_s+"-"+project.updated_on.to_i.to_s] do%>
<li>
<span class="user_icons_class"></span>
<% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count %>
<%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "project_list_menu hidden",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%>
<div class="user_navmore_box">
<ul class="<%#= count > 0 ? 'shild shildP':'subNavArrow'%>">
<li class="user_navmore_icons">
@ -32,7 +38,7 @@
<div class="cl"></div>
</li>
<li>
<% if ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count == 0 %>
<% if count == 0 %>
<%= link_to "屏蔽动态", shield_activities_path(:user_id => user.id, :project_id => project.id), :method => 'post',:remote => true,:class => "user_navmore_li" %>
<% else %>
<%= link_to "显示动态", show_acts_shield_activities_path(:user_id => user.id, :project_id => project.id),:method => 'delete',:remote => true,:class => "user_navmore_li" %>
@ -40,7 +46,7 @@
<div class="cl"></div>
</li>
<li>
<% if ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count == 0 %>
<% if wechat_count == 0 %>
<%= link_to "屏蔽微信消息", shield_wechat_messages_path(:user_id => user.id, :project_id => project.id), :method => 'post',:remote => true,:class => "user_navmore_li" %>
<% else %>
<%= link_to "接收微信消息", show_messages_shield_wechat_messages_path(:user_id => user.id, :project_id => project.id),:method => 'delete',:remote => true,:class => "user_navmore_li" %>
@ -60,6 +66,7 @@
</ul>
</div>
</li>
<% end %>
<% end %>
<% if all_count > (page.to_i+1) * 10%>

@ -1,5 +1,6 @@
<% unless activity.author.nil? %>
<div class="resources mt10" id="user_activity_<%= user_activity_id%>">
<% cache [:user_projectissue_activity,activity.id.to_s+"-"+User.current.logged?.to_s+"-"+(defined?(project_id)).to_s+"-"+(defined?(user_id)).to_s+"-"+(activity.editable?).to_s+"-"+(User.current.allowed_to?(:edit_issues, activity.project)).to_s+"-"+(User.current.allowed_to?(:delete_issues, activity.project)).to_s+"-"+(User.current.allowed_to?(:add_issues, activity.project)).to_s+"-"+activity.updated_on.to_i.to_s] do%>
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
@ -95,6 +96,7 @@
</div>
<div class="cl"></div>
</div>
<% end %>
<div id="div_user_issue_reply_<%=user_activity_id%>">
<%= render :partial => 'users/project_issue_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id} %>
</div>

@ -1,4 +1,6 @@
<div class="resources mt10" id="user_activity_<%= user_activity_id%>">
<% update_time = get_forge_act_message(activity, activity.class.to_s) %>
<% cache [:user_projectmessage_activity,activity.id.to_s+"-"+User.current.logged?.to_s+"-"+(activity.author.id == User.current.id).to_s+"-"+(activity.editable_by?(User.current)).to_s+"-"+(activity.destroyable_by?(User.current)).to_s+"-"+update_time] do%>
<div class="homepagePostBrief">
<div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
@ -29,7 +31,7 @@
发帖时间:<%= format_time(activity.created_on) %>
</div>
<div class="homepagePostDate fl ml15">
更新时间:<%= get_forge_act_message(activity, activity.class.to_s) %>
更新时间:<%= update_time %>
</div>
<div class="cl"></div>
<% if activity.parent_id.nil? %>
@ -81,6 +83,7 @@
</div>
<div class="cl"></div>
</div>
<% end %>
<% all_comments = []%>
<% count=get_all_children(all_comments, activity).count %>
<%# allow_delete = (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher,activity.course)) %>

@ -106,7 +106,7 @@
<% end %>
<% end %>
<%# end %>
<% if user_activities.count == 10%>
<% if user_activities.count == 5%>
<!--
<div id="show_more_activities" class="loadMore mt10 f_grey">点击展开更多<%#=link_to "", user_activities_path(@user.id,:type => type,:page => page),:id => "more_activities_link",:remote => "true",:class => "none" %></div>
-->

Loading…
Cancel
Save