<commit_before># == Schema Information
#
# Table name: absentee_reports
#
#  id          :integer(4)      not null, primary key
#  school_id   :integer(4)
#  report_date :date
#  enrolled    :integer(4)
#  absent      :integer(4)
#  created_at  :datetime
#  updated_at  :datetime
#

class AbsenteeReport < ActiveRecord::Base
  SEVERITY = {
      :low => {:min => 0.11000, :max => 0.14000},
      :medium => {:min => 0.14000, :max => 0.25000},
      :high => {:min => 0.25000, :max => 1.000},
      }
  belongs_to :school
  has_one :district, :through => :school

  named_scope :for_date, lambda{ |date|
    {
        :conditions => {:report_date => date}
    }
  }
  named_scope :for_date_range, lambda{ |start, finish|
    {
        :conditions => ["report_date >= ? and report_date <= ?", start, finish],
        :order => "report_date desc"
    }
  }
  named_scope :recent, lambda{|limit| {:limit => limit, :order => "report_date DESC"}}
  named_scope :recent_alerts_by_severity, lambda{|limit| {
      :limit => limit.to_i,
      :conditions => "(absent/enrolled) >= #{SEVERITY[:low][:min]}",
      :order => "(absent/enrolled) DESC"}}

  named_scope :absenses, lambda{{:conditions => ['absentee_reports.absent / absentee_reports.enrolled >= .11']}}
  named_scope :with_severity, lambda{|severity|
    range=SEVERITY[severity]
    { :conditions => ["(absent / enrolled) >= ? and (absent / enrolled) < ?", range[:min], range[:max]]
    }}

  def absentee_percentage
    ((absent.to_f / enrolled.to_f) * 100).to_f.round(2)
  end

  def severity
    return "low" if absentee_percentage >= (SEVERITY[:low][:min]*100) && absentee_percentage < (SEVERITY[:low][:max]*100)
    return "medium" if absentee_percentage >= (SEVERITY[:medium][:min]*100) && absentee_percentage < (SEVERITY[:medium][:max]*100)
    return "high" if absentee_percentage >= (SEVERITY[:high][:min]*100)
  end

  def self.render_graphs params
    if params[:adv] == 'true'
      param_switch = 'adv'
    else
      param_switch = 'simple'
    end

    school_name = params['school_'+param_switch].index('...').blank? ? CGI::unescape(params['school_'+param_switch]) : ""
    school_type = params['school_type_'+param_switch].index('...').blank? ? CGI::unescape(params['school_type_'+param_switch]) : ""
    schools     = School.search("#{school_name}").concat(School.search("#{school_type}"))
    schools.concat(School.search("#{params['zip_'+param_switch]}")) unless params['zip_'+param_switch].blank?

    options        = {:page => params[:page] || 1, :per_page => params[:limit] || 6}
    schools_uniq   = schools.uniq.map {|v| (schools-[v]).size < (schools.size - 1) ? v : nil}.compact
    schools_uniq   = schools_uniq.blank? ? schools.paginate(options) : schools_uniq.paginate(options)
    start_date     = params['startdt_'+param_switch].index('...').blank? ? Time.local(params['startdt_'+param_switch]) : Time.local(2010,"aug",1,0,0)
    end_date       = params['enddt_'+param_switch].index('...').blank? ? Time.local(params['enddt_'+param_switch]) : Time.local(2011,"sep",30,23,59)
    image_names    = []
    rrd_path       = Dir.pwd << "/rrd/"
    rrd_image_path = Dir.pwd << "/public/rrd/"
    rrd_tool       = if File.exist?(doc_yml = RAILS_ROOT+"/config/rrdtool.yml")
      YAML.load(IO.read(doc_yml))[Rails.env]["rrdtool_path"] + "/rrdtool"
    end

    schools_uniq.each do |school|
      school_name    = school.display_name.gsub(" ", "_")
      tea_id  = school.tea_id
      #build_rrd rrd_path, rrd_tool, params, school_name unless File.exists?("#{rrd_path}#{school_name}_absenteeism.rrd")
      total_enrolled = (2..5).to_a[rand((2..5).to_a.length - 1)] * 100
      for i in 0..29
        total_absent  = (20..150).to_a[rand((20..150).to_a.length - 1)]
        report_date   = Time.local(2010,Time.now().strftime("%b").downcase,(i + 1),0,0)
        ds_values     = self.build_fake_data report_date.to_i.to_s, total_enrolled, total_absent, params['absent_'+param_switch].index("Confirmed").blank?
        RRD.send_later(:update, "#{rrd_path}#{tea_id}_absenteeism.rrd", ds_values, "#{rrd_tool}")
      end<commit_msg>Lost default time on absentee reports, probably during a merge<commit_after># == Schema Information
#
# Table name: absentee_reports
#
#  id          :integer(4)      not null, primary key
#  school_id   :integer(4)
#  report_date :date
#  enrolled    :integer(4)
#  absent      :integer(4)
#  created_at  :datetime
#  updated_at  :datetime
#

class AbsenteeReport < ActiveRecord::Base
  SEVERITY = {
      :low => {:min => 0.11000, :max => 0.14000},
      :medium => {:min => 0.14000, :max => 0.25000},
      :high => {:min => 0.25000, :max => 1.000},
      }
  belongs_to :school
  has_one :district, :through => :school

  named_scope :for_date, lambda{ |date|
    {
        :conditions => {:report_date => date}
    }
  }
  named_scope :for_date_range, lambda{ |start, finish|
    {
        :conditions => ["report_date >= ? and report_date <= ?", start, finish],
        :order => "report_date desc"
    }
  }
  named_scope :recent, lambda{|limit| {:limit => limit, :order => "report_date DESC"}}
  named_scope :recent_alerts_by_severity, lambda{|limit| {
      :limit => limit.to_i,
      :conditions => "(absent/enrolled) >= #{SEVERITY[:low][:min]}",
      :order => "(absent/enrolled) DESC"}}

  named_scope :absenses, lambda{{:conditions => ['absentee_reports.absent / absentee_reports.enrolled >= .11']}}
  named_scope :with_severity, lambda{|severity|
    range=SEVERITY[severity]
    { :conditions => ["(absent / enrolled) >= ? and (absent / enrolled) < ?", range[:min], range[:max]]
    }}

  def absentee_percentage
    ((absent.to_f / enrolled.to_f) * 100).to_f.round(2)
  end

  def severity
    return "low" if absentee_percentage >= (SEVERITY[:low][:min]*100) && absentee_percentage < (SEVERITY[:low][:max]*100)
    return "medium" if absentee_percentage >= (SEVERITY[:medium][:min]*100) && absentee_percentage < (SEVERITY[:medium][:max]*100)
    return "high" if absentee_percentage >= (SEVERITY[:high][:min]*100)
  end

  def self.render_graphs params
    if params[:adv] == 'true'
      param_switch = 'adv'
    else
      param_switch = 'simple'
    end

    school_name = params['school_'+param_switch].index('...').blank? ? CGI::unescape(params['school_'+param_switch]) : ""
    school_type = params['school_type_'+param_switch].index('...').blank? ? CGI::unescape(params['school_type_'+param_switch]) : ""
    schools     = School.search("#{school_name}").concat(School.search("#{school_type}"))
    schools.concat(School.search("#{params['zip_'+param_switch]}")) unless params['zip_'+param_switch].blank?

    options        = {:page => params[:page] || 1, :per_page => params[:limit] || 6}
    schools_uniq   = schools.uniq.map {|v| (schools-[v]).size < (schools.size - 1) ? v : nil}.compact
    schools_uniq   = schools_uniq.blank? ? schools.paginate(options) : schools_uniq.paginate(options)
    start_date     = params['startdt_'+param_switch].index('...').blank? ? Time.local(params['startdt_'+param_switch]) : Time.now - 60.days
    end_date       = params['enddt_'+param_switch].index('...').blank? ? Time.local(params['enddt_'+param_switch]) : Time.now
    image_names    = []
    rrd_path       = Dir.pwd << "/rrd/"
    rrd_image_path = Dir.pwd << "/public/rrd/"
    rrd_tool       = if File.exist?(doc_yml = RAILS_ROOT+"/config/rrdtool.yml")
      YAML.load(IO.read(doc_yml))[Rails.env]["rrdtool_path"] + "/rrdtool"
    end

    schools_uniq.each do |school|
      school_name    = school.display_name.gsub(" ", "_")
      tea_id  = school.tea_id
      #build_rrd rrd_path, rrd_tool, params, school_name unless File.exists?("#{rrd_path}#{school_name}_absenteeism.rrd")
      total_enrolled = (2..5).to_a[rand((2..5).to_a.length - 1)] * 100
      for i in 0..29
        total_absent  = (20..150).to_a[rand((20..150).to_a.length - 1)]
        report_date   = Time.local(2010,Time.now().strftime("%b").downcase,(i + 1),0,0)
        ds_values     = self.build_fake_data report_date.to_i.to_s, total_enrolled, total_absent, params['absent_'+param_switch].index("Confirmed").blank?
        RRD.send_later(:update, "#{rrd_path}#{tea_id}_absenteeism.rrd", ds_values, "#{rrd_tool}")
      end
{'fraction_non_alphanumeric': 0.17915349063488203, 'fraction_numerical': 0.024446606665045, 'mean_word_length': 3.7367511520737327, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1756332', 'n_tokens_mistral': 3126, 'n_tokens_neox': 2945, 'n_words': 485}