Fixing indentation and some code styles - no behavioral change intended

pull/6827/head
Gregor Schmidt 13 years ago
parent 80f4d630a2
commit 40798ce8a8
  1. 46
      app/models/sprint.rb

@ -32,18 +32,16 @@ class Sprint < Version
" OR (version_settings.project_id is NULL)", " OR (version_settings.project_id is NULL)",
project.id, VersionSetting::DISPLAY_LEFT] } } project.id, VersionSetting::DISPLAY_LEFT] } }
named_scope :displayed_right, lambda { |project| { :include => :version_settings, named_scope :displayed_right, lambda { |project| {:include => :version_settings,
:conditions => ["version_settings.project_id = ? AND version_settings.display = ?", :conditions => ["version_settings.project_id = ? AND version_settings.display = ?",
project.id, VersionSetting::DISPLAY_RIGHT] } } project.id, VersionSetting::DISPLAY_RIGHT]} }
def stories(project, options = {} ) def stories(project, options = {} )
Story.sprint_backlog(project, self, options) Story.sprint_backlog(project, self, options)
end end
def points def points
return stories.inject(0){|sum, story| sum + story.story_points.to_i} stories.inject(0) { |sum, story| sum + story.story_points.to_i }
end end
def has_wiki_page def has_wiki_page
@ -55,13 +53,11 @@ class Sprint < Version
template = project.wiki.find_page(Setting.plugin_redmine_backlogs[:wiki_template]) template = project.wiki.find_page(Setting.plugin_redmine_backlogs[:wiki_template])
return false if template && page.text == template.text return false if template && page.text == template.text
return true true
end end
def wiki_page def wiki_page
if ! project.wiki return '' unless project.wiki
return ''
end
self.update_attribute(:wiki_page_title, Wiki.titleize(self.name)) if wiki_page_title.blank? self.update_attribute(:wiki_page_title, Wiki.titleize(self.name)) if wiki_page_title.blank?
@ -69,30 +65,30 @@ class Sprint < Version
template = project.wiki.find_page(Setting.plugin_redmine_backlogs[:wiki_template]) template = project.wiki.find_page(Setting.plugin_redmine_backlogs[:wiki_template])
if template and not page if template and not page
page = WikiPage.new(:wiki => project.wiki, :title => self.wiki_page_title) page = project.wiki.pages.build(:title => self.wiki_page_title)
page.content = WikiContent.new page.build_content(:text => "h1. #{self.name}\n\n#{template.text}")
page.content.text = "h1. #{self.name}\n\n#{template.text}"
page.save! page.save!
end end
return wiki_page_title wiki_page_title
end end
def days(cutoff = nil, alldays = false) def days(cutoff = nil, alldays = false)
# assumes mon-fri are working days, sat-sun are not. this # assumes mon-fri are working days, sat-sun are not. this
# assumption is not globally right, we need to make this configurable. # assumption is not globally right, we need to make this configurable.
cutoff = self.effective_date if cutoff.nil? cutoff = self.effective_date if cutoff.nil?
return (self.start_date .. cutoff).select {|d| alldays || (d.wday > 0 and d.wday < 6) }
(self.start_date .. cutoff).select {|d| alldays || (d.wday > 0 and d.wday < 6) }
end end
def eta def eta
return nil if ! self.start_date return nil unless self.start_date
dpp = self.project.scrum_statistics.info[:average_days_per_point] dpp = self.project.scrum_statistics.info[:average_days_per_point]
return nil if !dpp return nil unless dpp
# assume 5 out of 7 are working days # assume 5 out of 7 are working days
return self.start_date + Integer(self.points * dpp * 7.0/5) self.start_date + Integer(self.points * dpp * 7.0/5)
end end
def has_burndown? def has_burndown?
@ -101,23 +97,24 @@ class Sprint < Version
def activity def activity
bd = self.burndown('up') bd = self.burndown('up')
return false if !bd return false if bd.blank?
# assume a sprint is active if it's only 2 days old # assume a sprint is active if it's only 2 days old
return true if bd.remaining_hours.size <= 2 return true if bd.remaining_hours.size <= 2
return Issue.exists?(['fixed_version_id = ? and ((updated_on between ? and ?) or (created_on between ? and ?))', self.id, -2.days.from_now, Time.now, -2.days.from_now, Time.now]) Issue.exists?(['fixed_version_id = ? and ((updated_on between ? and ?) or (created_on between ? and ?))',
self.id, -2.days.from_now, Time.now, -2.days.from_now, Time.now])
end end
def burndown(project, burn_direction = nil) def burndown(project, burn_direction = nil)
return nil if not self.has_burndown? return nil unless self.has_burndown?
@cached_burndown ||= Burndown.new(self, project, burn_direction) @cached_burndown ||= Burndown.new(self, project, burn_direction)
return @cached_burndown
end end
def self.generate_burndown(only_current = true) def self.generate_burndown(only_current = true)
if only_current if only_current
conditions = ["? between start_date and effective_date", Date.today] conditions = ["? BETWEEN start_date AND effective_date", Date.today]
else else
conditions = "1 = 1" conditions = "1 = 1"
end end
@ -133,7 +130,8 @@ class Sprint < Version
private private
def start_and_end_dates def start_and_end_dates
errors.add_to_base(:cannot_end_before_it_starts) if self.effective_date && self.start_date && self.start_date >= self.effective_date if self.effective_date && self.start_date && self.start_date >= self.effective_date
errors.add_to_base(:cannot_end_before_it_starts)
end
end end
end end

Loading…
Cancel
Save