<commit_before>module Boostify

  if Boostify.orm == :active_record
    class Donation < ActiveRecord::Base
      include Boostify::Models::ActiveRecord::Donation
    end
  end

  class Donation
    include Boostify::Models::Mongoid::Donation if Boostify.orm == :mongoid
    include ActiveModel::ForbiddenAttributesProtection

    belongs_to :charity, class_name: 'Boostify::Charity',
      primary_key: :boost_id
    belongs_to :donatable, class_name: Boostify.donatable_class.to_s
    belongs_to :user, class_name: Boostify.current_user_class.to_s

    before_create :generate_token
    after_save :update_charity_cached_fields

    validates :donatable, :commission, presence: true
    validate :lock_charity

    def pixel_url
      [
        Boostify.tracker_api_endpoint, '?',
         HMACAuth::Signature.
           sign(query_params, secret: Boostify.partner_secret).to_query
      ].join ''
    end

    def self.from_donatable(donatable)
      self.new(
        donatable: donatable,
        amount: donatable.donatable_amount,
        commission: donatable.donatable_commission)
    end

    def to_param
      token
    end

    private

      def query_params
        {
          referal: {
            shop_id: Boostify.partner_id.to_s,
            charity_id: charity_id.to_s
          },<commit_msg>only validate donatable_id instead of donatable because of multitenancy<commit_after>module Boostify

  if Boostify.orm == :active_record
    class Donation < ActiveRecord::Base
      include Boostify::Models::ActiveRecord::Donation
    end
  end

  class Donation
    include Boostify::Models::Mongoid::Donation if Boostify.orm == :mongoid
    include ActiveModel::ForbiddenAttributesProtection

    belongs_to :charity, class_name: 'Boostify::Charity',
      primary_key: :boost_id
    belongs_to :donatable, class_name: Boostify.donatable_class.to_s
    belongs_to :user, class_name: Boostify.current_user_class.to_s

    before_create :generate_token
    after_save :update_charity_cached_fields

    validates :donatable_id, :commission, presence: true
    validate :lock_charity

    def pixel_url
      [
        Boostify.tracker_api_endpoint, '?',
         HMACAuth::Signature.
           sign(query_params, secret: Boostify.partner_secret).to_query
      ].join ''
    end

    def self.from_donatable(donatable)
      self.new(
        donatable: donatable,
        amount: donatable.donatable_amount,
        commission: donatable.donatable_commission)
    end

    def to_param
      token
    end

    private

      def query_params
        {
          referal: {
            shop_id: Boostify.partner_id.to_s,
            charity_id: charity_id.to_s
          },
{'fraction_non_alphanumeric': 0.07426661715558856, 'fraction_numerical': 0.0, 'mean_word_length': 2.944363103953148, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2466327', 'n_tokens_mistral': 849, 'n_tokens_neox': 822, 'n_words': 162}