From 9728277005972cc3e8b9a998ebc2a3e0932ffea1 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 28 Jul 2015 16:04:40 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E3=80=81=E6=AF=8F=E6=AC=A1=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E6=98=BE=E7=A4=BA13=E6=9D=A1=202=E3=80=81=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E9=A1=B5=E9=9D=A2=E3=80=81=E4=BB=96=E7=9A=84?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E3=80=81=E4=BB=96=E7=9A=84=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E3=80=81=E7=95=99=E8=A8=80=E7=AD=89=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 91 +---------------------------- app/helpers/users_helper.rb | 7 ++- app/views/users/show.html.erb | 66 --------------------- 3 files changed, 5 insertions(+), 159 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 67cebd261..5cb43f4e8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -426,95 +426,6 @@ class UsersController < ApplicationController render :layout=>nil end - # def user_course_activities - # @list = [] - # lastid = nil - # if params[:lastid]!=nil && !params[:lastid].empty? - # lastid = params[:lastid]; - # end - # - # user_ids = [] - # if @user == User.current - # watcher = User.watched_by(@user) - # watcher.push(User.current) - # user_ids = watcher.map{|x| x.id} - # else - # user_ids << @user.id - # end - # - # query_rec_count = 8 - # query_times = 10 #query_times次没查到query_rec_count条记录就不查了 - # query_i = 0; - # while( true ) - # query_i = query_i+1 - # if(query_i>query_times) - # break - # end - # query = Activity.where(user_id: user_ids) - # if(lastid != nil) - # query = query.where("id < ?",lastid) - # end - # lastid,item_list = query_activities(query,'course'); - # for item in item_list - # @list << item - # if @list.count() >= query_rec_count - # break - # end - # end - # if @list.count() >= query_rec_count - # break - # end - # if lastid == nil - # break - # end - # end - # render :layout=>nil - # end - # - # def user_project_activities - # @list = [] - # lastid = nil - # if params[:lastid]!=nil && !params[:lastid].empty? - # lastid = params[:lastid]; - # end - # - # user_ids = [] - # if @user == User.current - # watcher = User.watched_by(@user) - # watcher.push(User.current) - # user_ids = watcher.map{|x| x.id} - # else - # user_ids << @user.id - # end - # - # query_rec_count = 8 - # query_times = 10 #query_times次没查到query_rec_count条记录就不查了 - # query_i = 0; - # while( true ) - # query_i = query_i+1 - # if(query_i>query_times) - # break - # end - # query = Activity.where(user_id: user_ids) - # if(lastid != nil) - # query = query.where("id < ?",lastid) - # end - # lastid,item_list = query_activities(query,'project'); - # for item in item_list - # @list << item - # if @list.count() >= query_rec_count - # break - # end - # end - # if @list.count() >= query_rec_count - # break - # end - # if lastid == nil - # break - # end - # end - # render :action=>'user_course_activities',:layout=>nil - # end def user_course_activities lastid = nil if params[:lastid]!=nil && !params[:lastid].empty? @@ -573,7 +484,7 @@ class UsersController < ApplicationController query = query.where("#{Activity.table_name}.id < ?",lastid) end query = query.order("#{Activity.table_name}.id desc") - @list = query_activities(query); + @list = query_activities(query) render :action=>'user_course_activities',:layout=>nil end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 0b2d74ee8..8a49f8e2d 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -364,14 +364,15 @@ module UsersHelper end def query_activities(query) - list = query.limit(8).all - result = []; + list = query.limit(13).all + result = [] for item in list container = get_activity_container(item) result << { :item=>item,:e=>container } end - return result + result end + def get_activity_container activity return activity.activity_container end diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 2c91f394f..3b1ee93c8 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -29,49 +29,6 @@ <% end %>