From a6c7766b00b4eacc51c96f1021c97e3ee884e887 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 9 Mar 2016 18:06:26 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=8D=E8=83=BD=E5=88=A0=E9=99=A4=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/trustie/gitlab/helper.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/trustie/gitlab/helper.rb b/lib/trustie/gitlab/helper.rb index 9fb1f5735..54bc4620e 100644 --- a/lib/trustie/gitlab/helper.rb +++ b/lib/trustie/gitlab/helper.rb @@ -40,6 +40,11 @@ module Trustie username: user.login, confirm: "true") user.gid = u.id + user.save + end + if user.gid.nil? + user.gid = u.id + user.save end change_password(u.id, user.hashed_password, user.salt) rescue => e From fa3fd56686962c2a317f9f44204844384c2029bf Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 10 Mar 2016 15:48:39 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E9=A2=98=E5=BA=93=E5=8F=91=E9=80=81?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=9A=84=E5=BC=B9=E6=A1=86=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ea984aa80..96fb8cfce 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -423,7 +423,7 @@ class UsersController < ApplicationController end def choose_user_course - homework = HomeworkCommon.find params[:homework].to_i + homework = HomeworkCommon.find params[:send_id].to_i if !params[:search].nil? search = "%#{params[:search].to_s.strip.downcase}%" @course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id} and #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)} From 08cb7b642c9471640863deeedc75ea7fe48afc0f Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 10 Mar 2016 16:43:25 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E9=99=84=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_upload_course_files.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/files/_upload_course_files.erb b/app/views/files/_upload_course_files.erb index 133b8b4d6..0a35c783c 100644 --- a/app/views/files/_upload_course_files.erb +++ b/app/views/files/_upload_course_files.erb @@ -25,7 +25,7 @@
- +
From c18634be8645634fe573c0cfbe0d76c89cbf066a Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 11 Mar 2016 15:21:40 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E3=80=82=E6=96=B0=E9=97=BB=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/news_controller.rb | 32 +++++++++--------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 0962deb10..f45e1dbd7 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -107,32 +107,18 @@ class NewsController < ApplicationController def show # 更新news对应的forge_messages的消息viewed字段 + ids = @news.comments.map { |comment| comment.id }.join(",") unless @news.comments.nil? if @project - query_message_news = @news.forge_messages + # 更新新闻 + query_message_news = ForgeMessage.where("forge_message_id =? and user_id =? and viewed =?", @news.id, User.current.id, 0).first + # 更新新闻的时候一并更新回复 + ForgeMessage.where("forge_message_id in (#{ids}) and forge_message_type = 'Comment' and user_id = #{User.current.id}").update_all(:viewed => true) unless ids.blank? else - query_message_news = @news.course_messages + query_message_news = CourseMessage.where("course_message_id =? and user_id =? and viewed =?", @news.id, User.current.id, 0).first + CourseMessage.where("course_message_id in (#{ids}) and course_message_type = 'Comment' and user_id = #{User.current.id}").update_all(:viewed => true) unless ids.blank? end - query_message_news.each do |query| - if User.current.id == query.user_id - query.update_attributes(:viewed => true) - end - end - # 更新项目新闻的评阅的消息viewed字段 - current_message_comments = @news.comments - current_message_comments.each do |current_message_comment| - if @project - query_message_comment = current_message_comment.forge_messages - else - query_message_comment = current_message_comment.course_messages - end - query_message_comment.each do |query| - if User.current.id == query.user_id - query.update_attributes(:viewed => true) - end - end - end - # end - + query_message_news.update_attribute(:viewed, true) unless query_message_news.nil? + # over cs = CoursesService.new result = cs.show_course_news params,User.current @news = result[:news] From 8079254089ed1b402eed840fa69f2a0fffcebabd Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 11 Mar 2016 15:51:45 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 ++ app/controllers/organizations_controller.rb | 2 ++ app/controllers/projects_controller.rb | 2 ++ app/controllers/users_controller.rb | 4 ++++ db/migrate/20160311072540_add_visits_to_user.rb | 5 +++++ db/migrate/20160311072622_add_visits_to_project.rb | 5 +++++ db/migrate/20160311072718_add_visits_to_course.rb | 5 +++++ db/migrate/20160311072819_add_visits_to_organization.rb | 5 +++++ db/schema.rb | 6 +++++- 9 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20160311072540_add_visits_to_user.rb create mode 100644 db/migrate/20160311072622_add_visits_to_project.rb create mode 100644 db/migrate/20160311072718_add_visits_to_course.rb create mode 100644 db/migrate/20160311072819_add_visits_to_organization.rb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 708ac9a14..08559b2ad 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -838,6 +838,8 @@ class CoursesController < ApplicationController # render_403 # return # end + # 统计访问量 + @course.update_attribute(: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/organizations_controller.rb b/app/controllers/organizations_controller.rb index f225e7f50..711663c3d 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -69,6 +69,8 @@ class OrganizationsController < ApplicationController def show if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) @organization = Organization.find(params[:id]) + # 统计访问量 + @organization.update_attribute(:visits, @organization.visits.to_i + 1) if params[:org_subfield_id] @org_subfield = OrgSubfield.find(params[:org_subfield_id]) @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 3d5030c29..05c80a9fc 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -298,6 +298,8 @@ class ProjectsController < ApplicationController if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) return end + # 统计访问量 + @project.update_attribute(:visits, @project.visits.to_i + 1) =begin cond = @project.project_condition(Setting.display_subprojects_issues?) has = { diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 96fb8cfce..7fe146926 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1174,6 +1174,10 @@ class UsersController < ApplicationController end def show + # 统计访问量 + unless User.current == @user + @user.update_attribute(:visits, @user.visits.to_i + 1) + end #更新用户申请成为课程老师或教辅消息的状态 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/db/migrate/20160311072540_add_visits_to_user.rb b/db/migrate/20160311072540_add_visits_to_user.rb new file mode 100644 index 000000000..2169a4b0b --- /dev/null +++ b/db/migrate/20160311072540_add_visits_to_user.rb @@ -0,0 +1,5 @@ +class AddVisitsToUser < ActiveRecord::Migration + def change + add_column :users, :visits, :integer, :default => 0 + end +end diff --git a/db/migrate/20160311072622_add_visits_to_project.rb b/db/migrate/20160311072622_add_visits_to_project.rb new file mode 100644 index 000000000..1e67d9409 --- /dev/null +++ b/db/migrate/20160311072622_add_visits_to_project.rb @@ -0,0 +1,5 @@ +class AddVisitsToProject < ActiveRecord::Migration + def change + add_column :projects, :visits, :integer, :default => 0 + end +end diff --git a/db/migrate/20160311072718_add_visits_to_course.rb b/db/migrate/20160311072718_add_visits_to_course.rb new file mode 100644 index 000000000..4d4b682cf --- /dev/null +++ b/db/migrate/20160311072718_add_visits_to_course.rb @@ -0,0 +1,5 @@ +class AddVisitsToCourse < ActiveRecord::Migration + def change + add_column :courses, :visits, :integer, :default => 0 + end +end diff --git a/db/migrate/20160311072819_add_visits_to_organization.rb b/db/migrate/20160311072819_add_visits_to_organization.rb new file mode 100644 index 000000000..74bbcb5c9 --- /dev/null +++ b/db/migrate/20160311072819_add_visits_to_organization.rb @@ -0,0 +1,5 @@ +class AddVisitsToOrganization < ActiveRecord::Migration + def change + add_column :organizations, :visits, :integer, :default => 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index abaafdf80..d738b90c4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160310033019) do +ActiveRecord::Schema.define(:version => 20160311072819) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -508,6 +508,7 @@ ActiveRecord::Schema.define(:version => 20160310033019) do t.integer "is_excellent", :default => 0 t.integer "excellent_option", :default => 0 t.integer "is_copy", :default => 0 + t.integer "visits", :default => 0 end create_table "custom_fields", :force => true do |t| @@ -1284,6 +1285,7 @@ ActiveRecord::Schema.define(:version => 20160310033019) do t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.boolean "allow_guest_download", :default => true + t.integer "visits", :default => 0 end create_table "phone_app_versions", :force => true do |t| @@ -1443,6 +1445,7 @@ ActiveRecord::Schema.define(:version => 20160310033019) do t.integer "acts_count", :default => 0 t.integer "journals_count", :default => 0 t.integer "boards_reply_count", :default => 0 + t.integer "visits", :default => 0 end add_index "projects", ["lft"], :name => "index_projects_on_lft" @@ -1902,6 +1905,7 @@ ActiveRecord::Schema.define(:version => 20160310033019) do t.string "mail_notification", :default => "", :null => false t.string "salt", :limit => 64 t.integer "gid" + t.integer "visits", :default => 0 end add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id"