<commit_before>module RailsAdmin
  MainController.class_eval do
    include OverrideActionsHelper
    include RestApiHelper
    include SwaggerHelper
    include AlgorithmHelper
    include NotebooksHelper
    include FiltersHelper

    alias_method :rails_admin_list_entries, :list_entries
    before_action :update_filters_session
    before_action :get_data_type_filter

    def list_entries(model_config = @model_config, auth_scope_key = :index, additional_scope = get_association_scope_from_params, pagination = !(params[:associated_collection] || params[:all] || params[:bulk_ids]))
      scope = rails_admin_list_entries(model_config, auth_scope_key, additional_scope, pagination)
      if (model = model_config.abstract_model.model).is_a?(Class)
        if model.include?(CrossOrigin::Document)
          origins = []
          acc = Account.current
          model.origins.each do |origin|
            if (even = (params[origin_param="#{origin}_origin"] || (acc && acc.meta[origin_param])).to_i.even?)
              origins << origin
            end
            acc.meta[origin_param] = (even ? 0 : 1) if acc
          end
          origins << nil if origins.include?(:default)
          scope = scope.any_in(origin: origins)
        end

        filter_token = Cenit::Token.where(token: session[:filters][@model_name]).first if session[:filters][@model_name]
        criteria = filter_token.data['criteria'] if filter_token.try(:data)
        scope = scope.and(criteria) if criteria.is_a?(Hash)

      elsif (output = Setup::AlgorithmOutput.where(id: params[:algorithm_output]).first) &&
        output.data_type == model.data_type<commit_msg>Fix bug in the requests of the selection components<commit_after>module RailsAdmin
  MainController.class_eval do
    include OverrideActionsHelper
    include RestApiHelper
    include SwaggerHelper
    include AlgorithmHelper
    include NotebooksHelper
    include FiltersHelper

    alias_method :rails_admin_list_entries, :list_entries
    before_action :update_filters_session
    before_action :get_data_type_filter

    def list_entries(model_config = @model_config, auth_scope_key = :index, additional_scope = get_association_scope_from_params, pagination = !(params[:associated_collection] || params[:all] || params[:bulk_ids]))
      scope = rails_admin_list_entries(model_config, auth_scope_key, additional_scope, pagination)
      if (model = model_config.abstract_model.model).is_a?(Class)
        if model.include?(CrossOrigin::Document)
          origins = []
          acc = Account.current
          model.origins.each do |origin|
            if (even = (params[origin_param="#{origin}_origin"] || (acc && acc.meta[origin_param])).to_i.even?)
              origins << origin
            end
            acc.meta[origin_param] = (even ? 0 : 1) if acc
          end
          origins << nil if origins.include?(:default)
          scope = scope.any_in(origin: origins)
        end

        # Skip filters in ajax request of associated collection (Ex: Requests to get items of select components)
        unless request.xhr? && params[:associated_collection].present?
          filter_token = Cenit::Token.where(token: session[:filters][@model_name]).first if session[:filters][@model_name]
          criteria = filter_token.data['criteria'] if filter_token.try(:data)
          scope = scope.and(criteria) if criteria.is_a?(Hash)
        end

      elsif (output = Setup::AlgorithmOutput.where(id: params[:algorithm_output]).first) &&
        output.data_type == model.data_type
{'fraction_non_alphanumeric': 0.09954878736604625, 'fraction_numerical': 0.0011280315848843769, 'mean_word_length': 3.4955640050697085, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, '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': '252910', 'n_tokens_mistral': 1002, 'n_tokens_neox': 987, 'n_words': 211}