lib/jira-profiler/project.rb
def sprints
      if @sprints.nil?

        # Create references
        @sprints         = ActiveSupport::OrderedHash.new()
        @sprint_schedule = ActiveSupport::OrderedHash.new()

        # Get the list of sprint names and IDs for this project from Jira
        rapid_view = self.class.get("/rest/greenhopper/1.0/sprintquery/#{id}")
        rapid_view['sprints'].each do |item|
          @sprints[item['name']] = JiraProfiler::Sprint.new(
            :project => self,
            :id      => item['id'],
            :name    => item['name']
          )
        end

        # Check to see if a valid project log file is provided
        sprint_schedule_filepath = "#{JiraProfiler.config.data_directory}/#{name.to_snake_case}_sprint_schedule.csv"
        unless File.exists?(sprint_schedule_filepath)
          logger.info "Did not find sprint schedule file at #{sprint_schedule_filepath}"
        else
          logger.info "Overriding Jira data with values found in sprint schedule file at #{sprint_schedule_filepath}"

          # If a project log file is found, correct Jira's data with its contents
          data = CSV.read(log_filepath, { encoding: "UTF-8", headers: true, header_converters: :symbol, converters: :all})
          data.each do |row|
            from_date = Date.strptime(row[:from], "%m/%d/%y")
            # Correct Jira's sprint data
            sprint = @sprints[row[:sprint].to_s]
            sprint.start_date = from_date,
            sprint.end_date   = Date.strptime(row[:to], "%m/%d/%y"),
            sprint.note       = row[:note]
          end

        end

        # Create a reference of the start dates for all sprints
        @sprints.each do |sprint|
          @sprint_schedule[sprint.start_date.as_sortable_date] = sprint
        end

      end
      @sprints
    end
# The manually created table of sprint names with corresponding start and end dates
The manually created table of sprint names with corresponding start and end dates
The manually created table of sprint names with corresponding start and end dates
def sprints
      if @sprints.nil?
        @sprints         = ActiveSupport::OrderedHash.new()
        @sprint_schedule = ActiveSupport::OrderedHash.new()
        rapid_view = self.class.get("/rest/greenhopper/1.0/sprintquery/#{id}")
        rapid_view['sprints'].each do |item|
          @sprints[item['name']] = JiraProfiler::Sprint.new(
            :project => self,
            :id      => item['id'],
            :name    => item['name']
          )
        end
        sprint_schedule_filepath = "#{JiraProfiler.config.data_directory}/#{name.to_snake_case}_sprint_schedule.csv"
        unless File.exists?(sprint_schedule_filepath)
          logger.info "Did not find sprint schedule file at #{sprint_schedule_filepath}"
        else
          logger.info "Overriding Jira data with values found in sprint schedule file at #{sprint_schedule_filepath}"
          data = CSV.read(log_filepath, { encoding: "UTF-8", headers: true, header_converters: :symbol, converters: :all})
          data.each do |row|
            from_date = Date.strptime(row[:from], "%m/%d/%y")
            sprint = @sprints[row[:sprint].to_s]
            sprint.start_date = from_date,
            sprint.end_date   = Date.strptime(row[:to], "%m/%d/%y"),
            sprint.note       = row[:note]
          end
        end
        @sprints.each do |sprint|
          @sprint_schedule[sprint.start_date.as_sortable_date] = sprint
        end
      end
      @sprints
    end
def sprints if @sprints . nil? @sprints = ActiveSupport :: OrderedHash . new ( ) @sprint_schedule = ActiveSupport :: OrderedHash . new ( ) rapid_view = self . class . get ( "/rest/greenhopper/1.0/sprintquery/#{id}" ) rapid_view [ 'sprints' ] . each do | item | @sprints [ item [ 'name' ] ] = JiraProfiler :: Sprint . new ( :project => self , :id => item [ 'id' ] , :name => item [ 'name' ] ) end sprint_schedule_filepath = "#{JiraProfiler.config.data_directory}/#{name.to_snake_case}_sprint_schedule.csv" unless File . exists? ( sprint_schedule_filepath ) logger . info "Did not find sprint schedule file at #{sprint_schedule_filepath}" else logger . info "Overriding Jira data with values found in sprint schedule file at #{sprint_schedule_filepath}" data = CSV . read ( log_filepath , { encoding : "UTF-8" , headers : true , header_converters : :symbol , converters : :all } ) data . each do | row | from_date = Date . strptime ( row [ :from ] , "%m/%d/%y" ) sprint = @sprints [ row [ :sprint ] . to_s ] sprint . start_date = from_date , sprint . end_date = Date . strptime ( row [ :to ] , "%m/%d/%y" ) , sprint . note = row [ :note ] end end @sprints . each do | sprint | @sprint_schedule [ sprint . start_date . as_sortable_date ] = sprint end end @sprints end
The manually created table of sprint names with corresponding start and end dates
The manually created table of sprint names with corresponding start and end dates
# Create references # Get the list of sprint names and IDs for this project from Jira # Check to see if a valid project log file is provided # If a project log file is found, correct Jira's data with its contents # Correct Jira's sprint data # Create a reference of the start dates for all sprints