<commit_before>abstract class ApplicationRecord
  # Infers the table name with bad pluralization
  def self.table_name
    {{ @type.stringify }}.split(/(?=[A-Z][^A-Z])/).sort.map { |n| n + "s" }.join("_").downcase
  end

  # Generate insert query from properties. Used in save.
  def self.insert_query
    %<INSERT INTO #{table_name} (#{{{ @type.instance_vars.join(", ") }}}) VALUES (#{{{ @type.instance_vars.map { "?" }.join(", ") }}})>
  end

  # Retrieve first record
  def self.first
    from_rs(db.query("SELECT * FROM #{table_name} LIMIT 1")).first
  end

  # Count records
  def self.count
    db.query("SELECT COUNT(*) FROM #{table_name}") do |rs|
      rs.each do
        return rs.read(Int32)
      end
    end

    0
  end
end<commit_msg>Simplify count<commit_after>abstract class ApplicationRecord
  # Infers the table name with bad pluralization
  def self.table_name
    {{ @type.stringify }}.split(/(?=[A-Z][^A-Z])/).sort.map { |n| n + "s" }.join("_").downcase
  end

  # Generate insert query from properties. Used in save.
  def self.insert_query
    %<INSERT INTO #{table_name} (#{{{ @type.instance_vars.join(", ") }}}) VALUES (#{{{ @type.instance_vars.map { "?" }.join(", ") }}})>
  end

  # Retrieve first record
  def self.first
    from_rs(db.query("SELECT * FROM #{table_name} LIMIT 1")).first
  end

  # Count records
  def self.count
    db.query_one("SELECT COUNT(*) FROM #{table_name}", as: Int32)
  end
end
{'fraction_non_alphanumeric': 0.17154811715481172, 'fraction_numerical': 0.0048814504881450485, 'mean_word_length': 3.4290123456790123, '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': '2954673', 'n_tokens_mistral': 509, 'n_tokens_neox': 490, 'n_words': 127}