app/models/activities/accountability_report.rb
def inject_averages(force = false)
    load_results(:unique, force) if force || @results.empty?
    @log_step = :with_averages_added
    @overwrite_log = true
    puts "Collecting quarter totals", true
    puts "_ = Number of hours is blank      D = Duplicate (do not touch)     . = Number of hours is not blank"
    totals = {}
    average = {}
    for quarter in @quarters
      totals[quarter.abbrev] = []
    end
    for system_key, quarter_hash in @results
      for quarter_abbrev, activities in quarter_hash
        for activity in activities
          if activity[:number_of_hours].blank?
            print "_"
          elsif activity[:duplicate] == true
            print "D"
          else
            totals[quarter_abbrev] << activity[:number_of_hours] 
            print "."
          end
        end
      end
    end
    print "\n"
    puts "Calculating quarter averages", true
    for quarter in @quarters
      average[quarter.abbrev] = totals[quarter.abbrev].average
    end
    pp average
    puts "Injecting quarter averages into results", true
    puts "I = Average was injected      D = Average was injected (but record is duplicate)     . = No action needed"
    for system_key, quarter_hash in @results
      for quarter_abbrev, activities in quarter_hash
        for activity in activities
          if activity[:number_of_hours].blank?
            activity[:number_of_hours] = average[quarter_abbrev]
            print(activity[:duplicate] == true ? "D" : "I")
          else
            print "."
          end
        end
      end
    end
    puts "\n#{@results.size} unique students."
    puts "Saved results output to #{dump_results!(:with_averages_added)}"
  end
# Calculates the average number of hours of all non-course, non-duplicate activities for each quarter and then
# injects that into any activity without a +number_of_hours+ value defined.
Calculates the average number of hours of all non-course, non-duplicate activities for each quarter and then
injects that into any activity without a +number_of_hours+ value defined.
Calculates the average number of hours of all non - course non - duplicate activities for each quarter and then injects that into any activity without a + number_of_hours + value defined .
def inject_averages(force = false)
    load_results(:unique, force) if force || @results.empty?
    @log_step = :with_averages_added
    @overwrite_log = true
    puts "Collecting quarter totals", true
    puts "_ = Number of hours is blank      D = Duplicate (do not touch)     . = Number of hours is not blank"
    totals = {}
    average = {}
    for quarter in @quarters
      totals[quarter.abbrev] = []
    end
    for system_key, quarter_hash in @results
      for quarter_abbrev, activities in quarter_hash
        for activity in activities
          if activity[:number_of_hours].blank?
            print "_"
          elsif activity[:duplicate] == true
            print "D"
          else
            totals[quarter_abbrev] << activity[:number_of_hours] 
            print "."
          end
        end
      end
    end
    print "\n"
    puts "Calculating quarter averages", true
    for quarter in @quarters
      average[quarter.abbrev] = totals[quarter.abbrev].average
    end
    pp average
    puts "Injecting quarter averages into results", true
    puts "I = Average was injected      D = Average was injected (but record is duplicate)     . = No action needed"
    for system_key, quarter_hash in @results
      for quarter_abbrev, activities in quarter_hash
        for activity in activities
          if activity[:number_of_hours].blank?
            activity[:number_of_hours] = average[quarter_abbrev]
            print(activity[:duplicate] == true ? "D" : "I")
          else
            print "."
          end
        end
      end
    end
    puts "\n#{@results.size} unique students."
    puts "Saved results output to #{dump_results!(:with_averages_added)}"
  end
def inject_averages ( force = false ) load_results ( :unique , force ) if force || @results . empty? @log_step = :with_averages_added @overwrite_log = true puts "Collecting quarter totals" , true puts "_ = Number of hours is blank      D = Duplicate (do not touch)     . = Number of hours is not blank" totals = { } average = { } for quarter in @quarters totals [ quarter . abbrev ] = [ ] end for system_key , quarter_hash in @results for quarter_abbrev , activities in quarter_hash for activity in activities if activity [ :number_of_hours ] . blank? print "_" elsif activity [ :duplicate ] == true print "D" else totals [ quarter_abbrev ] << activity [ :number_of_hours ] print "." end end end end print "\n" puts "Calculating quarter averages" , true for quarter in @quarters average [ quarter . abbrev ] = totals [ quarter . abbrev ] . average end pp average puts "Injecting quarter averages into results" , true puts "I = Average was injected      D = Average was injected (but record is duplicate)     . = No action needed" for system_key , quarter_hash in @results for quarter_abbrev , activities in quarter_hash for activity in activities if activity [ :number_of_hours ] . blank? activity [ :number_of_hours ] = average [ quarter_abbrev ] print ( activity [ :duplicate ] == true ? "D" : "I" ) else print "." end end end end puts "\n#{@results.size} unique students." puts "Saved results output to #{dump_results!(:with_averages_added)}" end
Calculates the average number of hours of all non-course, non-duplicate activities for each quarter and then
injects that into any activity without a +number_of_hours+ value defined.
Calculates the average number of hours of all non - course non - duplicate activities for each quarter and then injects that into any activity without a + number_of_hours + value defined .
force