<commit_before>require 'zencoder'

class Shrine
  module Plugins
    module Zencoder
      class Importer < ActiveJob::Base
        queue_as :urgent

        def perform data, payload
          type, id = data['record']
          name = data['name']
          record = type.classify.constantize.find id
          attacher = record.send "#{name}_attacher"
          attacher.promote attacher.get, action: :store, payload: payload
        end
      end

      module AttacherMethods
        def start_encoding data
          ::Zencoder::Job.create input: url,
                                 outputs: encodings,
                                 notifications: [{ url: callback_url }]
        end

        def webhook_callback request
          Importer.perform_later dump, JSON.parse(request.body.read)
        end
      end

      module InstanceMethods<commit_msg>set test flag unless we are production<commit_after>require 'zencoder'

class Shrine
  module Plugins
    module Zencoder
      class Importer < ActiveJob::Base
        queue_as :urgent

        def perform data, payload
          type, id = data['record']
          name = data['name']
          record = type.classify.constantize.find id
          attacher = record.send "#{name}_attacher"
          attacher.promote attacher.get, action: :store, payload: payload
        end
      end

      module AttacherMethods
        def start_encoding data
          ::Zencoder::Job.create input: url,
                                 test: !Rails.env.production?,
                                 outputs: encodings,
                                 notifications: [{ url: callback_url }]
        end

        def webhook_callback request
          Importer.perform_later dump, JSON.parse(request.body.read)
        end
      end

      module InstanceMethods
{'fraction_non_alphanumeric': 0.0704070407040704, 'fraction_numerical': 0.0, 'mean_word_length': 1.7394578313253013, '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': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3720494', 'n_tokens_mistral': 466, 'n_tokens_neox': 455, 'n_words': 127}