From 466a25c1215a09e587d2eff40d08883e38148ccd Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 21 Jul 2016 17:02:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=90=8E=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81=E8=A1=A8update=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/forge_activity.rb | 9 +++++++-- lib/tasks/gitlab_act_project.rake | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index 47ebf4d0f..5fe953f66 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -25,8 +25,11 @@ class ForgeActivity < ActiveRecord::Base # 在个人动态里面增加当前动态 # 版本库提交动态不显示在用户动态中 + # Commit为版本库提交类型,因为是从gitlab获取,不能实时更新 def add_user_activity - if self.forge_act_type != "Changeset" + if self.forge_act_type == "Commit" + self.update_column(:updated_at, self.forge_act.committed_on) + else user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'").first if user_activity user_activity.save @@ -50,7 +53,9 @@ class ForgeActivity < ActiveRecord::Base # 项目提交动态不显示在组织动态中 def add_org_activity - if self.forge_act_type != "Changeset" + if self.forge_act_type == "Commit" + self.update_column(:updated_at, self.forge_act.committed_on) + else org_activity = OrgActivity.where("org_act_type = '#{self.forge_act_type.to_s}' and org_act_id = #{self.forge_act_id}").first if org_activity org_activity.updated_at = self.updated_at diff --git a/lib/tasks/gitlab_act_project.rake b/lib/tasks/gitlab_act_project.rake index 7ef336689..4ef4c4117 100644 --- a/lib/tasks/gitlab_act_project.rake +++ b/lib/tasks/gitlab_act_project.rake @@ -18,7 +18,6 @@ namespace :gitlab do commits = g.commits(project.gpid, :ref_name => g_default_branch, :page => page) commits.each do |commit| result = Commit.create(:project_id => project.id, :repository_id => project.gpid, :version => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at) - puts "result is #{result}" end end rescue Exception => e