<commit_before>module RailsAdmin
  module Models
    module Setup
      module JsonDataTypeAdmin
        extend ActiveSupport::Concern

        included do
          rails_admin do
            navigation_label 'Definitions'
            weight 111
            object_label_method { :custom_title }

            group :behavior do
              label 'Behavior'
              active false
            end

            configure :title

            configure :namespace, :enum_edit

            configure :name do
              read_only { !bindings[:object].new_record? }
            end

            configure :schema, :json_schema

            configure :schema_code, :json_schema do
              label 'Schema'
              help { 'Required' }
            end

            configure :storage_size, :decimal do
              pretty_value do
                if (objects = bindings[:controller].instance_variable_get(:@objects))
                  unless (max = bindings[:controller].instance_variable_get(:@max_storage_size))
                    bindings[:controller].instance_variable_set(:@max_storage_size, max = objects.collect { |data_type| data_type.storage_size }.max)
                  end
                  (bindings[:view].render partial: 'size_bar', locals: { max: max, value: bindings[:object].records_model.storage_size }).html_safe
                else
                  bindings[:view].number_to_human_size(value)
                end
              end
              read_only true
            end

            configure :before_save_callbacks do
              group :behavior
              inline_add false
              associated_collection_scope do
                limit = (associated_collection_cache_all ? nil : 30)
                Proc.new { |scope| scope.where(:parameters.with_size => 1).limit(limit) }
              end
            end

            configure :records_methods do
              group :behavior
              inline_add false
            end

            configure :data_type_methods do
              group :behavior
              inline_add false
            end

            configure :slug

            edit do
              field :namespace, :enum_edit, &RailsAdmin::Config::Fields::Base::SHARED_READ_ONLY
              field :name, &RailsAdmin::Config::Fields::Base::SHARED_READ_ONLY
              field :schema_code
              field :title, &RailsAdmin::Config::Fields::Base::SHARED_READ_ONLY
              field :slug
              field :before_save_callbacks, &RailsAdmin::Config::Fields::Base::SHARED_READ_ONLY
              field :records_methods, &RailsAdmin::Config::Fields::Base::SHARED_READ_ONLY
              field :data_type_methods, &RailsAdmin::Config::Fields::Base::SHARED_READ_ONLY
            end

            list do
              field :namespace
              field :name
              field :slug
              field :storage_size
              field :updated_at
            end

            show do
              field :namespace
              field :title
              field :name
              field :slug
              field :storage_size
              field :schema
              field :before_save_callbacks
              field :records_methods
              field :data_type_methods

              field :_id
              field :created_at
              #field :creator
              field :updated_at
              #field :updater
            end

            fields :namespace, :name, :slug, :storage_size, :updated_at

            filter_query_fields :namespace, :name
          end
        end

      end
    end
  end
end<commit_msg>Code warnings for JSON data types<commit_after>module RailsAdmin
  module Models
    module Setup
      module JsonDataTypeAdmin
        extend ActiveSupport::Concern

        included do
          rails_admin do
            navigation_label 'Definitions'
            weight 111
            object_label_method { :custom_title }

            group :behavior do
              label 'Behavior'
              active false
            end

            configure :title

            configure :namespace, :enum_edit

            configure :name do
              read_only { !bindings[:object].new_record? }
            end

            configure :schema, :json_schema

            configure :code_warnings, :code_warnings

            configure :schema_code, :json_schema do
              label 'Schema'
              help { 'Required' }
            end

            configure :storage_size, :decimal do
              pretty_value do
                if (objects = bindings[:controller].instance_variable_get(:@objects))
                  unless (max = bindings[:controller].instance_variable_get(:@max_storage_size))
                    bindings[:controller].instance_variable_set(:@max_storage_size, max = objects.collect { |data_type| data_type.storage_size }.max)
                  end
                  (bindings[:view].render partial: 'size_bar', locals: { max: max, value: bindings[:object].records_model.storage_size }).html_safe
                else
                  bindings[:view].number_to_human_size(value)
                end
              end
              read_only true
            end

            configure :before_save_callbacks do
              group :behavior
              inline_add false
              associated_collection_scope do
                limit = (associated_collection_cache_all ? nil : 30)
                Proc.new { |scope| scope.where(:parameters.with_size => 1).limit(limit) }
              end
            end

            configure :records_methods do
              group :behavior
              inline_add false
            end

            configure :data_type_methods do
              group :behavior
              inline_add false
            end

            configure :slug

            edit do
              field :namespace, :enum_edit, &RailsAdmin::Config::Fields::Base::SHARED_READ_ONLY
              field :name, &RailsAdmin::Config::Fields::Base::SHARED_READ_ONLY
              field :code_warnings
              field :schema_code
              field :title, &RailsAdmin::Config::Fields::Base::SHARED_READ_ONLY
              field :slug
              field :before_save_callbacks, &RailsAdmin::Config::Fields::Base::SHARED_READ_ONLY
              field :records_methods, &RailsAdmin::Config::Fields::Base::SHARED_READ_ONLY
              field :data_type_methods, &RailsAdmin::Config::Fields::Base::SHARED_READ_ONLY
            end

            list do
              field :namespace
              field :name
              field :slug
              field :storage_size
              field :updated_at
            end

            show do
              field :namespace
              field :title
              field :name
              field :slug
              field :storage_size
              field :code_warnings
              field :schema
              field :before_save_callbacks
              field :records_methods
              field :data_type_methods

              field :_id
              field :created_at
              #field :creator
              field :updated_at
              #field :updater
            end

            fields :namespace, :name, :slug, :storage_size, :updated_at

            filter_query_fields :namespace, :name
          end
        end

      end
    end
  end
end
{'fraction_non_alphanumeric': 0.06524688008681498, 'fraction_numerical': 0.0016277807921866521, 'mean_word_length': 1.497628726287263, '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': '1456477', 'n_tokens_mistral': 1819, 'n_tokens_neox': 1733, 'n_words': 427}