<commit_before>module MessagesMa
  class Message
    module Scopes
      def self.extended(base)
        t = Arel::Table.new(base.table_name)
        c = Arel::Table.new(Chain.table_name)

        base.scope :with, lambda{|user| base.where(t[:sender].eq(user.id).or(t[:recipients].matches("% #{user.id}\n%"))) }

        base.scope :for, lambda{|user| base.where(t[:recipients].matches("% #{user.id}\n%")) }

        base.scope :by, lambda{|user| base.where(:sender => user.id) }
        
        base.scope :not_archived_for, lambda { |user| 
            base.joins(:chain).where(c[:archived_for].does_not_match("% #{user.id}\n%") ) 
        }

        base.scope :archived_for, lambda { |user| 
            base.joins(:chain).where(c[:archived_for].matches("% #{user.id}\n%") ) 
        }

        base.scope :top, lambda{ base.where(:last => true) }

        base.scope :reversed, lambda { base.order('created_at DESC')}

        base.scope :messages_with, lambda {|user| base
                                                     .top
                                                     .with(user)
                                                     .not_archived_for(user)
                                                     .joins(:chain)
                                                     .reversed }
       
        base.scope :messages_for, lambda {|user| base
                                                     .top
                                                     .for(user)
                                                     .not_archived_for(user)
                                                     .joins(:chain)
                                                     .reversed }

        base.scope :archived_messages_with, lambda {|user| base
                                                     .top
                                                     .with(user)
                                                     .archived_for(user)<commit_msg>minor<commit_after>module MessagesMa
  class Message
    module Scopes
      def self.extended(base)
        t = Arel::Table.new(base.table_name)
        c = Arel::Table.new(Chain.table_name)

        base.scope :with, lambda{|user| base.where(t[:sender].eq(user.id).or(t[:recipients].matches("% #{user.id}\n%"))) }

        base.scope :for, lambda{|user| base.where(t[:recipients].matches("% #{user.id}\n%")) }

        base.scope :by, lambda{|user| base.where(:sender => user.id) }
        
        base.scope :not_archived_for, lambda { |user| 
            base.joins(:chain).where(c[:archived_for].does_not_match("% #{user.id}\n%") ) 
        }

        base.scope :archived_for, lambda { |user| 
            base.joins(:chain).where(c[:archived_for].matches("% #{user.id}\n%") ) 
        }

        base.scope :top, lambda{ base.where(:last => true) }

        base.scope :reversed, base.order('created_at DESC')

        base.scope :messages_with, lambda {|user| base
                                                     .top
                                                     .with(user)
                                                     .not_archived_for(user)
                                                     .joins(:chain)
                                                     .reversed }
       
        base.scope :messages_for, lambda {|user| base
                                                     .top
                                                     .for(user)
                                                     .not_archived_for(user)
                                                     .joins(:chain)
                                                     .reversed }

        base.scope :archived_messages_with, lambda {|user| base
                                                     .top
                                                     .with(user)
                                                     .archived_for(user)
{'fraction_non_alphanumeric': 0.1131979695431472, 'fraction_numerical': 0.0, 'mean_word_length': 0.9480968858131488, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 52, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2220590', 'n_tokens_mistral': 929, 'n_tokens_neox': 882, 'n_words': 152}