<commit_before>class WelcomeController < ApplicationController

  def index

    @day = Chronic.parse(params[:date]) || previous_day

    harvest = Harvest.client( Harvest::Application::CONFIG['harvest']['subdomain'],  Harvest::Application::CONFIG['harvest']['login_email'],  Harvest::Application::CONFIG['harvest']['password'])
    # harvest.projects.all   # list out projects

    # client = Harvest::Client.new(:name => "Billable Company LTD.")
    # client = harvest.clients.create(client)
    # harvest.clients.find(client.id) # returns a Harvest::Client

    @users = Harvest::Application::CONFIG['user_emails'].to_s.gsub(' ', '').split(',').inject({}) { |h, elem| h[elem] = nil; h}
     # {"<EMAIL>" => nil, "<EMAIL>" => nil, "<EMAIL>" => nil, "<EMAIL>" => nil}

    # get all users
    h_users = harvest.users.all

    # update our local hash
    @users.each do |k,v|
      p = Person.new()
      p.info = h_users.select{|u| u.email == k }.first
      # raise p
      p.times = harvest.time.all(@day, p.info.id)

      @users[k] = p
    end

  end

  private

    def previous_day
      d = 1.day.ago
      # 0..6, Sun..Sat
      while d.wday < 2 || d.wday > 5
        d = d - 1.day
      end
      d
    end

end<commit_msg>Fixed bug in logic to find previous business day<commit_after>class WelcomeController < ApplicationController

  def index

    @day = Chronic.parse(params[:date]) || previous_day

    harvest = Harvest.client( Harvest::Application::CONFIG['harvest']['subdomain'],  Harvest::Application::CONFIG['harvest']['login_email'],  Harvest::Application::CONFIG['harvest']['password'])
    # harvest.projects.all   # list out projects

    # client = Harvest::Client.new(:name => "Billable Company LTD.")
    # client = harvest.clients.create(client)
    # harvest.clients.find(client.id) # returns a Harvest::Client

    @users = Harvest::Application::CONFIG['user_emails'].to_s.gsub(' ', '').split(',').inject({}) { |h, elem| h[elem] = nil; h}
     # {"<EMAIL>" => nil, "<EMAIL>" => nil, "<EMAIL>" => nil, "<EMAIL>" => nil}

    # get all users
    h_users = harvest.users.all

    # update our local hash
    @users.each do |k,v|
      p = Person.new()
      p.info = h_users.select{|u| u.email == k }.first
      # raise p
      p.times = harvest.time.all(@day, p.info.id)

      @users[k] = p
    end

  end

  private

    def previous_day
      d = 1.day.ago
      # 0..6, Sun..Sat
      while d.wday < 1 || d.wday > 5
        d = d - 1.day
      end
      d
    end

end
{'fraction_non_alphanumeric': 0.1719312275089964, 'fraction_numerical': 0.004798080767692923, 'mean_word_length': 2.891135303265941, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, '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': '4135965', 'n_tokens_mistral': 859, 'n_tokens_neox': 822, 'n_words': 189}