<commit_before>class AddUploadsCountToComments < ActiveRecord::Migration
  def self.up
    add_column :comments, :uploads_count, :integer, :default => 0
    Comment.update_all "uploads_count = (SELECT COUNT(*) FROM `uploads` WHERE uploads.comment_id = comments.id AND uploads.deleted_at IS NULL)", "deleted_at IS NULL"
  end

  def self.down
    remove_column :comments, :uploads_count
  end
end
<commit_msg>fix uploads_count migration for postgres and mysql<commit_after>class AddUploadsCountToComments < ActiveRecord::Migration
  def self.up
    add_column :comments, :uploads_count, :integer, :default => 0
    case ActiveRecord::Base.configurations[Rails.env]['adapter']
    when 'postgresql'
      Comment.update_all "uploads_count = (SELECT COUNT(*) FROM uploads,comments WHERE uploads.comment_id = comments.id AND uploads.deleted_at IS NULL)", "deleted_at IS NULL"
    else
      Comment.update_all "uploads_count = (SELECT COUNT(*) FROM uploads WHERE uploads.comment_id = comments.id AND uploads.deleted_at IS NULL)", "deleted_at IS NULL"
    end
  end

  def self.down
    remove_column :comments, :uploads_count
  end
end

{'fraction_non_alphanumeric': 0.09098939929328621, 'fraction_numerical': 0.0017667844522968198, 'mean_word_length': 4.870466321243524, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2493658', 'n_tokens_mistral': 353, 'n_tokens_neox': 343, 'n_words': 98}