issue创建和删除的时候,issues_count+1
This commit is contained in:
parent
1239a8b5af
commit
8758235364
|
@ -83,9 +83,9 @@ class Issue < ActiveRecord::Base
|
|||
attr_reader :current_journal
|
||||
|
||||
# fq
|
||||
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message, :act_as_at_message
|
||||
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message, :act_as_at_message, :add_issues_count
|
||||
after_update :be_user_score
|
||||
after_destroy :down_user_score
|
||||
after_destroy :down_user_score, :decrease_issues_count
|
||||
# after_create :be_user_score
|
||||
# end
|
||||
|
||||
|
@ -165,6 +165,18 @@ class Issue < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# 创建issue的时候,issues_count加1
|
||||
def add_issues_count
|
||||
issue_count = self.project.issues_count + 1
|
||||
self.project.update_attribute(:issues_count, issue_count)
|
||||
end
|
||||
|
||||
# 删除issue的时候,issues_count减1
|
||||
def decrease_issues_count
|
||||
issue_count = self.project.issues_count - 1
|
||||
self.project.update_attribute(:issues_count, issue_count)
|
||||
end
|
||||
|
||||
# 更新缺陷
|
||||
#def act_as_forge_message_update
|
||||
# unless self.author_id == self.assigned_to_id
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class StaticProjectBoards < ActiveRecord::Migration
|
||||
def up
|
||||
begin
|
||||
Project.all.each do |project|
|
||||
puts project.id
|
||||
unless project.boards.first.nil?
|
||||
|
@ -8,12 +7,8 @@ class StaticProjectBoards < ActiveRecord::Migration
|
|||
project.update_attribute(:boards_count, boards_count)
|
||||
end
|
||||
end
|
||||
ensure
|
||||
self.down
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
Project.update_all(:boards_count => false)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,11 +2,10 @@ class StaticProjectIssues < ActiveRecord::Migration
|
|||
def up
|
||||
Project.all.each do |project|
|
||||
issues_count = project.issues.count
|
||||
project.update_attribute(:issues_count, boards_count)
|
||||
project.update_attribute(:issues_count, issues_count)
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
Project.all.update_all(:issues_count => false)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
class StaticProjectNews < ActiveRecord::Migration
|
||||
def up
|
||||
Project.all.each do |project|
|
||||
unless project.news.nil?
|
||||
news_count = project.news.count
|
||||
project.update_attribute(:news_count, news_count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
Project.all.update_all(:news_count => false)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
class StaticProjectAttachments < ActiveRecord::Migration
|
||||
def up
|
||||
Project.all.each do |project|
|
||||
unless project.attachments.nil?
|
||||
attachments_count = project.attachments.count
|
||||
project.update_attribute(:attachments_count, attachments_count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
Project.all.update_all(:attachments_count => false)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
class StaticProjectActs < ActiveRecord::Migration
|
||||
def up
|
||||
Project.all.each do |project|
|
||||
acts_count = ForgeActivity.where("project_id = ?", project.id).count
|
||||
acts = ForgeActivity.where("project_id = ?", project.id)
|
||||
unless acts.blank?
|
||||
acts_count = acts.count
|
||||
puts project.id
|
||||
puts "acts_count is #{acts_count}"
|
||||
project.update_attribute(:acts_count, acts_count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
Project.all.update_all(:acts_count => false)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue