<commit_before>namespace :loomio do
  task tail_call: :environment do
    RubyVM::InstructionSequence.compile_option = {
      :tailcall_optimization => true,
      :trace_instruction => false
    }
  end

  task send_proposal_closing_soon: :environment do
    Delayed::Job.enqueue ProposalsClosingSoonJob.new
  end

  task close_lapsed_motions: :environment do
    MotionService.close_all_lapsed_motions
  end

  task send_missed_yesterday_email: :environment do
    SendMissedYesterdayEmail.to_subscribers!
  end

  task generate_error: :environment do
    raise "Testing error reporting for rake tasks. Chill, no action requied if you see this"
  end

  task refresh_likes: :environment do
    progress_bar = ProgressBar.create( format: "(\e[32m%c/%C\e[0m) %a |%B| \e[31m%e\e[0m ", progress_mark: "\e[32m/\e[0m", total: Comment.count )

    Comment.find_each do |c|
      progress_bar.increment
      c.refresh_liker_ids_and_names!
    end
  end

  task refresh_comment_versions: :environment do
    progress_bar = ProgressBar.create(format: "(\e[32m%c/%C\e[0m) %a |%B| \e[31m%e\e[0m ", progress_mark: "\e[32m/\e[0m", total: Comment.count )

    Comment.find_each(batch_size: 200) do |c|
      progress_bar.increment
      c.update_versions_count
    end
  end

  task refresh_discussion_versions: :environment do
    progress_bar = ProgressBar.create(format: "(\e[32m%c/%C\e[0m) %a |%B| \e[31m%e\e[0m ", progress_mark: "\e[32m/\e[0m", total: Discussion.count )

    Discussion.find_each(batch_size: 200) do |d|
      progress_bar.increment
      d.update_versions_count
    end
  end

  task fix_unread: :environment do
    puts "Recounting discussion reader counts"
    progress_bar = ProgressBar.create( format: "(\e[32m%c/%C\e[0m) %a |%B| \e[31m%e\e[0m ", progress_mark: "\e[32m/\e[0m", total: DiscussionReader.count )

    DiscussionReader.find_each do |dr|
      progress_bar.increment
      next unless dr.valid?
      next unless dr.discussion.present?
      next unless dr.user.present?
      dr.reset_counts!
    end
  end

  task tag_and_measure_cohorts: :environment do
    CohortService.tag_groups
    MeasurementService.measure_groups(Date.yesterday)
  end

  task measure_groups_lots: :environment do
    CohortService.tag_groups
    date = 10.weeks.ago.to_date
    while(date < Date.today) do
      puts 'hi'
      MeasurementService.measure_groups(date)
      puts "measured #{date}"
      date = date + 1.day
    end
  end

  task update_blog_stories: :environment do
    rss = SimpleRSS.parse open('http://blog.loomio.org/category/stories/feed/')
    BlogStory.destroy_all
    rss.items.each do |item|
      BlogStory.create(title: item[:title],
                       url: item[:link],
                       image_url: item[:media_content_url],
                       published_at: item[:pubDate])
    end
  end

  task notify_clients_of_update: :environment do
    MessageChannelService.publish({ version: Loomio::Version.current }, to: GlobalMessageChannel.instance)
  end
end<commit_msg>Make sure blog images are https<commit_after>namespace :loomio do
  task tail_call: :environment do
    RubyVM::InstructionSequence.compile_option = {
      :tailcall_optimization => true,
      :trace_instruction => false
    }
  end

  task send_proposal_closing_soon: :environment do
    Delayed::Job.enqueue ProposalsClosingSoonJob.new
  end

  task close_lapsed_motions: :environment do
    MotionService.close_all_lapsed_motions
  end

  task send_missed_yesterday_email: :environment do
    SendMissedYesterdayEmail.to_subscribers!
  end

  task generate_error: :environment do
    raise "Testing error reporting for rake tasks. Chill, no action requied if you see this"
  end

  task refresh_likes: :environment do
    progress_bar = ProgressBar.create( format: "(\e[32m%c/%C\e[0m) %a |%B| \e[31m%e\e[0m ", progress_mark: "\e[32m/\e[0m", total: Comment.count )

    Comment.find_each do |c|
      progress_bar.increment
      c.refresh_liker_ids_and_names!
    end
  end

  task refresh_comment_versions: :environment do
    progress_bar = ProgressBar.create(format: "(\e[32m%c/%C\e[0m) %a |%B| \e[31m%e\e[0m ", progress_mark: "\e[32m/\e[0m", total: Comment.count )

    Comment.find_each(batch_size: 200) do |c|
      progress_bar.increment
      c.update_versions_count
    end
  end

  task refresh_discussion_versions: :environment do
    progress_bar = ProgressBar.create(format: "(\e[32m%c/%C\e[0m) %a |%B| \e[31m%e\e[0m ", progress_mark: "\e[32m/\e[0m", total: Discussion.count )

    Discussion.find_each(batch_size: 200) do |d|
      progress_bar.increment
      d.update_versions_count
    end
  end

  task fix_unread: :environment do
    puts "Recounting discussion reader counts"
    progress_bar = ProgressBar.create( format: "(\e[32m%c/%C\e[0m) %a |%B| \e[31m%e\e[0m ", progress_mark: "\e[32m/\e[0m", total: DiscussionReader.count )

    DiscussionReader.find_each do |dr|
      progress_bar.increment
      next unless dr.valid?
      next unless dr.discussion.present?
      next unless dr.user.present?
      dr.reset_counts!
    end
  end

  task tag_and_measure_cohorts: :environment do
    CohortService.tag_groups
    MeasurementService.measure_groups(Date.yesterday)
  end

  task measure_groups_lots: :environment do
    CohortService.tag_groups
    date = 10.weeks.ago.to_date
    while(date < Date.today) do
      puts 'hi'
      MeasurementService.measure_groups(date)
      puts "measured #{date}"
      date = date + 1.day
    end
  end

  task update_blog_stories: :environment do
    rss = SimpleRSS.parse open('http://blog.loomio.org/category/stories/feed/')
    BlogStory.destroy_all
    rss.items.each do |item|
      BlogStory.create(title: item[:title],
                       url: item[:link],
                       image_url: item[:media_content_url].try(:gsub, "http://", "https://"),
                       published_at: item[:pubDate])
    end
  end

  task notify_clients_of_update: :environment do
    MessageChannelService.publish({ version: Loomio::Version.current }, to: GlobalMessageChannel.instance)
  end
end
{'fraction_non_alphanumeric': 0.10822368421052632, 'fraction_numerical': 0.014802631578947368, 'mean_word_length': 3.3653984206748024, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 1, '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': '1266880', 'n_tokens_mistral': 2167, 'n_tokens_neox': 2046, 'n_words': 434}