<commit_before>module Stagehand
  module Staging
    class CommitEntry < ActiveRecord::Base
      attr_writer :record

      self.table_name = 'stagehand_commit_entries'

      START_OPERATION = 'commit_start'
      END_OPERATION = 'commit_end'
      INSERT_OPERATION = 'insert'
      UPDATE_OPERATION = 'update'
      DELETE_OPERATION = 'delete'

      CONTROL_OPERATIONS = [START_OPERATION, END_OPERATION]
      CONTENT_OPERATIONS = [INSERT_OPERATION, UPDATE_OPERATION, DELETE_OPERATION]
      SAVE_OPERATIONS = [INSERT_OPERATION, UPDATE_OPERATION]

      scope :start_operations,   lambda { where(:operation => START_OPERATION) }
      scope :end_operations,     lambda { where(:operation => END_OPERATION) }
      scope :control_operations, lambda { where(:operation => CONTROL_OPERATIONS) }
      scope :content_operations, lambda { where(:operation => CONTENT_OPERATIONS) }
      scope :save_operations,    lambda { where(:operation => SAVE_OPERATIONS) }
      scope :delete_operations,  lambda { where(:operation => DELETE_OPERATION) }
      scope :uncontained,        lambda { where(:commit_id => nil) }
      scope :contained,          lambda { where.not(:commit_id => nil) }
      scope :not_in_progress,    lambda {
        joins("LEFT OUTER JOIN (#{ unscoped.select('session, MAX(id) AS start_id').uncontained.start_operations.group('session').to_sql }) AS active_starts
               ON active_starts.session = stagehand_commit_entries.session AND active_starts.start_id <= stagehand_commit_entries.id")
       .where("active_starts.start_id IS NULL") }

      def self.matching(object)
        keys = Array.wrap(object).collect {|entry| Stagehand::Key.generate(entry) }.compact
        sql = []
        interpolates = []
<commit_msg>Make it easy to list entries with records<commit_after>module Stagehand
  module Staging
    class CommitEntry < ActiveRecord::Base
      attr_writer :record

      self.table_name = 'stagehand_commit_entries'

      START_OPERATION = 'commit_start'
      END_OPERATION = 'commit_end'
      INSERT_OPERATION = 'insert'
      UPDATE_OPERATION = 'update'
      DELETE_OPERATION = 'delete'

      CONTROL_OPERATIONS = [START_OPERATION, END_OPERATION]
      CONTENT_OPERATIONS = [INSERT_OPERATION, UPDATE_OPERATION, DELETE_OPERATION]
      SAVE_OPERATIONS = [INSERT_OPERATION, UPDATE_OPERATION]

      scope :start_operations,   lambda { where(:operation => START_OPERATION) }
      scope :end_operations,     lambda { where(:operation => END_OPERATION) }
      scope :control_operations, lambda { where(:operation => CONTROL_OPERATIONS) }
      scope :content_operations, lambda { where(:operation => CONTENT_OPERATIONS) }
      scope :save_operations,    lambda { where(:operation => SAVE_OPERATIONS) }
      scope :delete_operations,  lambda { where(:operation => DELETE_OPERATION) }
      scope :with_record,        lambda { where.not(:record_id => nil) }
      scope :uncontained,        lambda { where(:commit_id => nil) }
      scope :contained,          lambda { where.not(:commit_id => nil) }
      scope :not_in_progress,    lambda {
        joins("LEFT OUTER JOIN (#{ unscoped.select('session, MAX(id) AS start_id').uncontained.start_operations.group('session').to_sql }) AS active_starts
               ON active_starts.session = stagehand_commit_entries.session AND active_starts.start_id <= stagehand_commit_entries.id")
       .where("active_starts.start_id IS NULL") }

      def self.matching(object)
        keys = Array.wrap(object).collect {|entry| Stagehand::Key.generate(entry) }.compact
        sql = []
        interpolates = []

{'fraction_non_alphanumeric': 0.10175145954962468, 'fraction_numerical': 0.0, 'mean_word_length': 3.577608142493639, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 20, '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': '2476321', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1021, 'n_words': 214}