<commit_before># frozen_string_literal: true
class RepositoryMaintenanceStatWorker
    include Sidekiq::Worker
    sidekiq_options queue: :repo_maintenance_stat, retry: 3

    def perform(repo_id)
        Repository.find(repo_id).gather_maintenance_stats
    end

    def self.enqueue(repo_id, priority: :medium)
        queue_name = "repo_maintenance_stat"
        case priority
        when :low
            queue_name = "repo_maintenance_stat_low"
        when :medium
            queue_name = "repo_maintenance_stat"
        when :high
            queue_name = "repo_maintenance_stat_high"
        else
            raise ArgumentError.new("Unknown priority! Please set to :low :medium or :high")
        end

        # override the queue name setting for the worker and queue up the work
        self.set(queue: queue_name).perform_async(repo_id)
    end
end<commit_msg>Make repo maintainence workers unique by repo<commit_after># frozen_string_literal: true
class RepositoryMaintenanceStatWorker
    include Sidekiq::Worker
    sidekiq_options queue: :repo_maintenance_stat, retry: 3, unique: :until_executed

    def perform(repo_id)
        Repository.find(repo_id).gather_maintenance_stats
    end

    def self.enqueue(repo_id, priority: :medium)
        queue_name = "repo_maintenance_stat"
        case priority
        when :low
            queue_name = "repo_maintenance_stat_low"
        when :medium
            queue_name = "repo_maintenance_stat"
        when :high
            queue_name = "repo_maintenance_stat_high"
        else
            raise ArgumentError.new("Unknown priority! Please set to :low :medium or :high")
        end

        # override the queue name setting for the worker and queue up the work
        self.set(queue: queue_name).perform_async(repo_id)
    end
end
{'fraction_non_alphanumeric': 0.06260387811634349, 'fraction_numerical': 0.00110803324099723, 'mean_word_length': 2.8507462686567164, 'pattern_counts': {'":': 0, '<': 3, '<?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': '522825', 'n_tokens_mistral': 516, 'n_tokens_neox': 507, 'n_words': 137}