<commit_before>module PatronusFati
  module DataModels
    module ReportedAttributes
      def self.included(klass)
        klass.extend RAClassMethods
        klass.property  :reported_online, DataMapper::Property::Boolean,  :default  => false
      end

      module RAClassMethods
        def reported_offline
          all(:reported_online => false)
        end

        def reported_online
          all(:reported_online => true)
        end
      end
    end

    module AutoVendorLookup
      def self.included(klass)
        klass.extend AVLClassMethods
        klass.property :vendor, DataMapper::Property::String, :length => 255

        klass.before(:save) do
          next if self.vendor || self.class.vendor_attribute.nil?
          result = Louis.lookup(attributes[self.class.vendor_attribute])
          self.vendor = result['long_vendor'] || result['short_vendor']
        end
      end

      module AVLClassMethods
        def vendor_attribute(attr = nil)
          @@vendor_attribute = attr if attr && properties[attr]
          @@vendor_attribute
        end
      end
    end

    module ExpirationAttributes
      def self.included(klass)
        klass.extend EAClassMethods
        klass.property  :last_seen_at,  DataMapper::Property::Integer,  :default  => Proc.new { Time.now.to_i }
      end

      def active?
        last_seen_at >= self.class.current_expiration_threshold
      end

      def seen!
        update(last_seen_at: Time.now.to_i)
      end

      def uptime
        Time.now.to_i - last_seen_at
      end

      module EAClassMethods
        def active
          all(:last_seen_at.gte => current_expiration_threshold)
        end

        def inactive
          all(:last_seen_at.lt => current_expiration_threshold)
        end

        def ordered_limit(num)
          all(:limit => num, :order => [ :last_seen_at.desc ])
        end
      end
    end
  end
end
<commit_msg>Make seen marking a critical save<commit_after>module PatronusFati
  module DataModels
    module ReportedAttributes
      def self.included(klass)
        klass.extend RAClassMethods
        klass.property  :reported_online, DataMapper::Property::Boolean,  :default  => false
      end

      module RAClassMethods
        def reported_offline
          all(:reported_online => false)
        end

        def reported_online
          all(:reported_online => true)
        end
      end
    end

    module AutoVendorLookup
      def self.included(klass)
        klass.extend AVLClassMethods
        klass.property :vendor, DataMapper::Property::String, :length => 255

        klass.before(:save) do
          next if self.vendor || self.class.vendor_attribute.nil?
          result = Louis.lookup(attributes[self.class.vendor_attribute])
          self.vendor = result['long_vendor'] || result['short_vendor']
        end
      end

      module AVLClassMethods
        def vendor_attribute(attr = nil)
          @@vendor_attribute = attr if attr && properties[attr]
          @@vendor_attribute
        end
      end
    end

    module ExpirationAttributes
      def self.included(klass)
        klass.extend EAClassMethods
        klass.property  :last_seen_at,  DataMapper::Property::Integer,  :default  => Proc.new { Time.now.to_i }
      end

      def active?
        last_seen_at >= self.class.current_expiration_threshold
      end

      def seen!
        update!(last_seen_at: Time.now.to_i)
      end

      def uptime
        Time.now.to_i - last_seen_at
      end

      module EAClassMethods
        def active
          all(:last_seen_at.gte => current_expiration_threshold)
        end

        def inactive
          all(:last_seen_at.lt => current_expiration_threshold)
        end

        def ordered_limit(num)
          all(:limit => num, :order => [ :last_seen_at.desc ])
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.07644467478621404, 'fraction_numerical': 0.0015548069448043534, 'mean_word_length': 2.1433224755700326, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '2543278', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1085, 'n_words': 243}