From acf4e15f09c1187b492ce143f152baae8f981db1 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 14 Apr 2016 10:26:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=95=B0=E5=B7=A6=E4=BE=A7?= =?UTF-8?q?=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 -- app/controllers/projects_controller.rb | 2 -- app/controllers/users_controller.rb | 2 -- app/helpers/application_helper.rb | 4 ++++ app/views/layouts/base_courses.html.erb | 4 ++++ app/views/layouts/base_projects.html.erb | 5 +++-- app/views/layouts/new_base_user.html.erb | 5 +++++ 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 515b94392..eb6c7e184 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -851,8 +851,6 @@ class CoursesController < ApplicationController # render_403 # return # end - # 统计访问量 - @course.update_column(:visits, @course.visits.to_i + 1) #更新创建课程消息状态 create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0) create_course_messages.update_all(:viewed => true) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 96e236265..e3d089312 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -299,8 +299,6 @@ class ProjectsController < ApplicationController if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) return end - # 统计访问量 - @project.update_column(:visits, @project.visits + 1) # over @author = params[:user_id].blank? ? nil : User.active.find(params[:user_id]) @page = params[:page] ? params[:page].to_i + 1 : 0 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e59e33516..dcf4b8118 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1206,8 +1206,6 @@ class UsersController < ApplicationController end def show - # 统计访问量 - @user.update_column(:visits, @user.visits.to_i + 1) unless User.current == @user #更新用户申请成为课程老师或教辅消息的状态 if params[:course_id] != nil join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?", diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 828123675..366cea06b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -33,6 +33,10 @@ module ApplicationHelper extend Forwardable def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter + def update_visiti_count container + container.update_column(:visits, container.visits + 1) + end + # Time 2015-03-24 15:27:29 # Author lizanle # Description 从硬盘上删除对应的资源文件 diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index ff7f20300..a9e859448 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -68,6 +68,10 @@ + <%# 更新访问数,刷新的时候更新访问次数 %> + <% update_visiti_count @course %> + <%# over %> +
+ + <%# 更新访问数,刷新的时候更新访问次数 %> + <% update_visiti_count @user %> + <%# over %> +