提交后更新项目动态表update时间

This commit is contained in:
huang 2016-07-21 17:02:50 +08:00
parent 472eb4736e
commit 466a25c121
2 changed files with 7 additions and 3 deletions

View File

@ -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

View File

@ -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