<commit_before>module Netzke
  module Communitypack
    # 2 grids - "container" and "collection" - bound with a one-to-many relationship.
    # The collection model should implement belongs_to in respect to the container model.
    #
    # Accepts the following config options:
    # * :container_model - name of the container model, e.g. "User"
    # * :collection_model - name of the collection model, e.g. "Issue" (belongs_to :user)
    # * :container_config (optional) - a config hash passed to the container grid
    # * :collection_config (optional) - a config hash passod to the collection grid
    # * :association (optional) - the name of the association used in belongs_to macro. Defaults to the underscored name of the container model.
    class OneToManyExplorer < Netzke::Basepack::BorderLayoutPanel
      js_mixin

      delegates_to_dsl :container_model, :collection_model, :container_config, :collection_config, :association

      js_properties(
        :prevent_header => true,
        :border => true
      )

      def configuration
        super.tap do |c|

          # merge default container and collection config with the one provided by the user
          c[:container_config] = {
            :region => :west,
            :class_name => "Netzke::Basepack::GridPanel"
          }.merge(c[:container_config] || {})

          c[:collection_config] = {
            :class_name => "Netzke::Basepack::GridPanel"
          }.merge(c[:collection_config] || {})

          # set default width/height for regions
          c[:container_config][:width] ||= 300 if [:west, :east].include?(c[:container_config][:region].to_sym)
          c[:container_config][:height] ||= 150 if [:north, :south].include?(c[:container_config][:region].to_sym)

          # use the shortcuts for models
          c[:container_config][:model] ||= c[:container_model]
          c[:collection_config][:model] ||= c[:collection_model]

          # we need to get the association reflection in order to properly set the collection grid scope
          container_class = c[:container_config][:model].constantize
          collection_class = c[:collection_config][:model].constantize
          c[:association] ||= c[:container_config][:model].underscore.to_sym # the belongs_to association, e.g. "user"

          association = collection_class.reflect_on_association(c[:association])

          # if we have extra scopes received in the config, take them into account!
          passed_scope = c[:collection_config][:scope] || {}
          passed_strong_default_attrs = c[:collection_config][:strong_default_attrs] || {}

          c[:items] = [
            c[:container_config].merge(:item_id => 'container'),


            c[:collection_config].merge(<commit_msg>Minor impr to OneToManyExplorer<commit_after>module Netzke
  module Communitypack
    # 2 grids - "container" and "collection" - bound with a one-to-many relationship.
    # The collection model should implement belongs_to in respect to the container model.
    #
    # Accepts the following config options:
    # * :container_model - name of the container model, e.g. "User"
    # * :collection_model - name of the collection model, e.g. "Issue" (belongs_to :user)
    # * :container_config (optional) - a config hash passed to the container grid
    # * :collection_config (optional) - a config hash passod to the collection grid
    # * :association (optional) - the name of the association used in belongs_to macro. Defaults to the underscored name of the container model.
    class OneToManyExplorer < Netzke::Basepack::BorderLayoutPanel
      js_mixin

      delegates_to_dsl :container_model, :collection_model, :container_config, :collection_config, :association

      js_properties(
        :prevent_header => true,
        :border => true
      )

      def configuration
        super.tap do |c|

          # merge default container and collection config with the one provided by the user
          c[:container_config] = {
            :region => :west,
            :class_name => "Netzke::Basepack::GridPanel"
          }.merge(c[:container_config] || {})

          c[:collection_config] = {
            :class_name => "Netzke::Basepack::GridPanel"
          }.merge(c[:collection_config] || {})

          # set default width/height for regions
          c[:container_config][:width] ||= 300 if [:west, :east].include?(c[:container_config][:region].to_sym)
          c[:container_config][:height] ||= 200 if [:north, :south].include?(c[:container_config][:region].to_sym)

          # figure out collection_class from config or from the passed component
          container_class = c[:container_config][:model].try(:constantize) || c[:container_config][:class_name].constantize.new.data_class
          collection_class = c[:collection_config][:model].try(:constantize) || c[:collection_config][:class_name].constantize.new.data_class

          # use the shortcuts for models
          c[:container_config][:model] ||= c[:container_model] || container_class.name
          c[:collection_config][:model] ||= c[:collection_model] || collection_class.name

          # we need to get the association reflection in order to properly set the collection grid scope
          c[:association] ||= c[:container_config][:model].underscore.to_sym # the belongs_to association, e.g. "user"

          association = collection_class.reflect_on_association(c[:association])

          # if we have extra scopes received in the config, take them into account!
          passed_scope = c[:collection_config][:scope] || {}
          passed_strong_default_attrs = c[:collection_config][:strong_default_attrs] || {}

          c[:items] = [
            c[:container_config].merge(:item_id => 'container'),


            c[:collection_config].merge(
{'fraction_non_alphanumeric': 0.11258620689655173, 'fraction_numerical': 0.002413793103448276, 'mean_word_length': 3.215843023255814, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '1782813', 'n_tokens_mistral': 1623, 'n_tokens_neox': 1571, 'n_words': 428}