<commit_before>module AbAdmin
  module Concerns
    module AdminAddition
      extend ActiveSupport::Concern

      included do
        attr_accessor :last_updated_timestamp
        validate :do_not_overwrite, if: :last_updated_timestamp
        scope(:admin, proc { all }) unless respond_to?(:admin)
        scope(:base, -> { all }) unless respond_to?(:base)
        scope :by_ids, lambda { |ids| where("#{quoted_table_name}.id IN (?)", AbAdmin.val_to_array(ids).push(0)) } unless respond_to?(:by_ids)

        class_attribute :batch_actions, instance_writer: false
        self.batch_actions = [:destroy]
      end

      def updated_timestamp
        res = [updated_at]
        res += translations.map(&:updated_at) if self.class.translates?
        res += updated_timestamp_associations.flat_map{|assoc| Array(send(assoc)).map(&:updated_timestamp) }
        res.max
      end

      def for_input_token
        {id: id, text: AbAdmin.safe_display_name(self).to_s}
      end

      def han
        "#{self.class.model_name.human(count: 1)} ##{self.id} #{AbAdmin.safe_display_name(self)}"
      end

      def token_data(method, options={})
        assoc = self.class.reflect_on_association(method)
        scope = send(method)
        scope = scope.reorder("#{assoc.options[:through]}.position") if options[:sortable]
        records = Array(scope)
        data = records.map(&:for_input_token)
        data = {
            pre: data.to_json,
            class: assoc.klass.name,
            multi: assoc.collection?,
            c: options.delete(:c),
            sortable: options.delete(:sortable)
        }
        if options[:geo_order]
          data[:c] ||= {}
          singular = self.class.model_name.singular
          data[:c].reverse_deep_merge!({with: {lat: "#{singular}_lat", lon: "#{singular}_lon"}})<commit_msg>Reject nils in updated_timestamp<commit_after>module AbAdmin
  module Concerns
    module AdminAddition
      extend ActiveSupport::Concern

      included do
        attr_accessor :last_updated_timestamp
        validate :do_not_overwrite, if: :last_updated_timestamp
        scope(:admin, proc { all }) unless respond_to?(:admin)
        scope(:base, -> { all }) unless respond_to?(:base)
        scope :by_ids, lambda { |ids| where("#{quoted_table_name}.id IN (?)", AbAdmin.val_to_array(ids).push(0)) } unless respond_to?(:by_ids)

        class_attribute :batch_actions, instance_writer: false
        self.batch_actions = [:destroy]
      end

      def updated_timestamp
        res = [updated_at]
        res += translations.map(&:updated_at) if self.class.translates?
        res += updated_timestamp_associations.flat_map{|assoc| Array(send(assoc)).map(&:updated_timestamp) }
        res.compact.max
      end

      def for_input_token
        {id: id, text: AbAdmin.safe_display_name(self).to_s}
      end

      def han
        "#{self.class.model_name.human(count: 1)} ##{self.id} #{AbAdmin.safe_display_name(self)}"
      end

      def token_data(method, options={})
        assoc = self.class.reflect_on_association(method)
        scope = send(method)
        scope = scope.reorder("#{assoc.options[:through]}.position") if options[:sortable]
        records = Array(scope)
        data = records.map(&:for_input_token)
        data = {
            pre: data.to_json,
            class: assoc.klass.name,
            multi: assoc.collection?,
            c: options.delete(:c),
            sortable: options.delete(:sortable)
        }
        if options[:geo_order]
          data[:c] ||= {}
          singular = self.class.model_name.singular
          data[:c].reverse_deep_merge!({with: {lat: "#{singular}_lat", lon: "#{singular}_lon"}})
{'fraction_non_alphanumeric': 0.127134724857685, 'fraction_numerical': 0.0010843046896177825, 'mean_word_length': 2.7386018237082066, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4540557', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1117, 'n_words': 210}