<commit_before># -*- encoding : utf-8 -*-
# Add colors functions to model
module Colorable
  extend ActiveSupport::Concern
  included do
    attr_accessor :modified_palette

    has_many :colors, as: :colorable
    has_many :search_colors, through: :colors

    # if you want modify colors from model form
    attr_accessible :colors_attributes, :modified_palette
    accepts_nested_attributes_for :colors, update_only: true

    after_create :process_colors

    scope :by_color, -> colors {
      if !colors.blank?
        col = SearchColor.where('color in (?)', colors).pluck(:id)
        col_in = col.join(',')
        joins("inner join(select colorable_id, sum(distance) as dist, sum(search_factor) as search_factor
              from colors
              where search_color_id IN (#{col_in}) AND search_factor > 2 AND distance < 6500
              group by colorable_id having COUNT(colorable_id) = #{col.length})<commit_msg>remove distance because it is not working as intented for now<commit_after># -*- encoding : utf-8 -*-
# Add colors functions to model
module Colorable
  extend ActiveSupport::Concern
  included do
    attr_accessor :modified_palette

    has_many :colors, as: :colorable
    has_many :search_colors, through: :colors

    # if you want modify colors from model form
    attr_accessible :colors_attributes, :modified_palette
    accepts_nested_attributes_for :colors, update_only: true

    after_create :process_colors

    scope :by_color, -> colors {
      if !colors.blank?
        col = SearchColor.where('color in (?)', colors).pluck(:id)
        col_in = col.join(',')
        joins("inner join(select colorable_id, sum(distance) as dist, sum(search_factor) as search_factor
              from colors
              where search_color_id IN (#{col_in}) AND search_factor > 2
              group by colorable_id having COUNT(colorable_id) = #{col.length})
{'fraction_non_alphanumeric': 0.08941798941798942, 'fraction_numerical': 0.004232804232804233, 'mean_word_length': 3.3471264367816094, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 7, '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': '4900273', 'n_tokens_mistral': 554, 'n_tokens_neox': 536, 'n_words': 164}