<commit_before>module ActiveWorker
  module JobQueue
    class QueueManager

      def active_jobs(configuration_ids)
        workers = Resque.working.select do|w|
          configuration_ids.include? configuration_id_from_worker(w)
        end
        workers.map do |w|
          create_job_hash_from_worker(w)
        end
      end

      def configuration_id_from_worker(worker)
        params_from_worker(worker).first
      end

      def create_job_hash_from_worker(worker)
        worker_id = worker.to_s.split(":")
        host = worker_id[0]
        pid = worker_id[1]
        queues = worker_id[2].split(",")
        {"host" => host, "queues" => queues, "pid" => pid, "args" =>  args_from_worker(worker)}
      end

      def params_from_worker(worker)
        args_from_worker(worker)["params"]
      end
<commit_msg>[ryan] added active jobs, renamed to active jobs by configurations<commit_after>module ActiveWorker
  module JobQueue
    class QueueManager

      def active_jobs
        Resque.working.map {|w| create_job_hash_from_worker(w)}
      end

      def active_jobs_for_configurations(configuration_ids)
        workers = Resque.working.select do|w|
          configuration_ids.include? configuration_id_from_worker(w)
        end
        workers.map do |w|
          create_job_hash_from_worker(w)
        end
      end

      def configuration_id_from_worker(worker)
        params_from_worker(worker).first
      end

      def create_job_hash_from_worker(worker)
        worker_id = worker.to_s.split(":")
        host = worker_id[0]
        pid = worker_id[1]
        queues = worker_id[2].split(",")
        {"host" => host, "queues" => queues, "pid" => pid, "args" =>  args_from_worker(worker)}
      end

      def params_from_worker(worker)
        args_from_worker(worker)["params"]
      end

{'fraction_non_alphanumeric': 0.09359605911330049, 'fraction_numerical': 0.003284072249589491, 'mean_word_length': 2.6487025948103793, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 11, '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': '3007630', 'n_tokens_mistral': 574, 'n_tokens_neox': 561, 'n_words': 109}