<commit_before>desc "This task is called by the Heroku scheduler add-on"
task :update_data => :environment do
  puts "Updating data"

  gids = BuildLinks.last_night.uniq
  gids.each do |gid|
    SeedHelper.seed_gid(gid)
  end

  games = Game.where(game_date: Date.today.prev_day)
  games.each do |game|
    Game.set_calls(game)
  end

  Day.create_days(games)
  Umpire.update_ranking
  Umpire.update_year_ranking(Date.today.year)
  
  puts "updating data complete"

  last_day = Day.order(:game_date).last

  if last_day.game_date == Date.today.prev_day
    client = Twitter::REST::Client.new do |config|
      config.consumer_key        = ENV["TWITTER_API_KEY"]
      config.consumer_secret     = ENV["TWITTER_API_SECRET_KEY"]
      config.access_token        = ENV["TWITTER_ACCESS_TOKEN"]
      config.access_token_secret = ENV["TWITTER_TOKEN_SECRET"]
    end

    client.update(last_day.tweet)
  end

end
<commit_msg>separated tweet from update data in scheduler<commit_after>desc "This task is called by the Heroku scheduler add-on"
task :update_data => :environment do
  puts "Updating data"

  gids = BuildLinks.last_night.uniq
  gids.each do |gid|
    SeedHelper.seed_gid(gid)
  end

  games = Game.where(game_date: Date.today.prev_day)
  games.each do |game|
    Game.set_calls(game)
  end

  Day.create_days(games)
  Umpire.update_ranking
  Umpire.update_year_ranking(Date.today.year)
  
  puts "updating data complete"
end

task :tweet => :environment do 
  last_day = Day.order(:game_date).last

  if last_day.game_date == Date.today.prev_day
    client = Twitter::REST::Client.new do |config|
      config.consumer_key        = ENV["TWITTER_API_KEY"]
      config.consumer_secret     = ENV["TWITTER_API_SECRET_KEY"]
      config.access_token        = ENV["TWITTER_ACCESS_TOKEN"]
      config.access_token_secret = ENV["TWITTER_TOKEN_SECRET"]
    end

    client.update(last_day.tweet)
  end
end


{'fraction_non_alphanumeric': 0.09853249475890985, 'fraction_numerical': 0.0, 'mean_word_length': 3.678921568627451, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '4193381', 'n_tokens_mistral': 724, 'n_tokens_neox': 686, 'n_words': 131}