From 0c0dfbd09354585c6a3e003c74dd967effd92718 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 19 Jul 2016 17:38:11 +0800 Subject: [PATCH] =?UTF-8?q?changeset=E5=85=B3=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/changeset.rb | 6 +++--- lib/tasks/gitlab_act_project.rake | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 20b919d37..ae1faf40a 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -22,9 +22,7 @@ class Changeset < ActiveRecord::Base #after_save :be_user_score # user_score has_many :filechanges, :class_name => 'Change', :dependent => :delete_all - # fq - has_many :forge_activities, :class_name => 'ForgeActivity', :as => :forge_act, :dependent => :destroy - # end + has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy #Added by nie has_one :project_status, :dependent => :destroy @@ -59,6 +57,8 @@ class Changeset < ActiveRecord::Base validates :committed_on, presence: true validates :commit_date, presence: true validates :scmid, uniqueness: {scope: :repository_id, allow_nil: true} + attr_accessible :product + attr_accessible :type scope :visible, lambda {|*args| includes(:repository => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args)) diff --git a/lib/tasks/gitlab_act_project.rake b/lib/tasks/gitlab_act_project.rake index 91990b175..259fdc58e 100644 --- a/lib/tasks/gitlab_act_project.rake +++ b/lib/tasks/gitlab_act_project.rake @@ -3,7 +3,8 @@ namespace :gitlab do task :forge_acts => :environment do begin g = Gitlab.client - projects = Project.find_by_sql("select * from projects where gpid is not null") + # projects = Project.find_by_sql("select * from projects where gpid is not null") + projects = Project.find("select * from projects where gpid is not null and id != 2") projects.each do |project| g_project = g.project(project.gpid) # 获取默认分支 @@ -15,7 +16,7 @@ namespace :gitlab do (0..pages).each do |page| commits = g.commits(project.gpid, :ref_name => g_default_branch, :page => page) commits.each do |commit| - Changeset.create(:project_id => project.id, :repository_id => project.gpid, :revision => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at) + Changeset.create(:project_id => project.id, :repository_id => project.gpid, :revision => commit.id, :committer => commit.author_email, :comments => Redmine::CodesetUtil.to_utf8(commit.title, 'UTF-8'), :committed_on => commit.created_at, :type => true) end end end