You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: organization_webhook_health_service.rb
    path of file: ./repos/classroom/app/services
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

require "ruby-progressbar"

class OrganizationWebhookHealthService
  class Result
    def self.success
      new(:success)
    end

    def self.failed(error)
      new(:failed, error: error)
    end

    attr_reader :error

    def initialize(status, error: nil)
      @status = status
      @error  = error
    end

    def success?
      @status == :success
    end

    def failed?
      @status == :failed
    end
  end

  def initialize(all_organizations: false)
    @all_organizations = all_organizations
  end

  # Public: Iterates through OrganizationWebhook records and ensures
  # that each record has an active and working webhook.
  #
  # all_organizations - Flag that specifies whether to iterate all OrganizationWebhooks,
    
  def perform
    org_webhook_count = (@all_organizations ? OrganizationWebhook : OrganizationWebhook.where(github_id: nil)).count

    progress_bar = ProgressBar.create(
      title: "Iterating over OrganizationWebhooks",
      starting_at: 0,
      total: org_webhook_count,
      format: "%t: %a %e %c/%C (%j%%) %R |%B|",
      throttle_rate: 0.5,
      output: Rails.env.test? ? StringIO.new : STDERR
    )

    success_org_webhooks = []
    failed_org_webhooks = {}
    (@all_organizations ? OrganizationWebhook : OrganizationWebhook.where(github_id: nil))
      .find_in_batches(batch_size: 100) do |organization_webhooks|
        organization_webhooks.each do |organization_webhook|
          result = ensure_organization_webhook_exists!(organization_webhook)
          if result.success?
            success_org_webhooks << organization_webhook.id
          else
            failed_org_webhooks[result.error.class.to_s] ||= []
            failed_org_webhooks[result.error.class.to_s] << organization_webhook.id
          end
          progress_bar.increment
        end
      end