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: build_release_undo_changesets.rb
    path of file: ./repos/workarea/core/app/workers/workarea
    
    the code of the file until where you have to start completion: module Workarea
  class BuildReleaseUndoChangesets
    include Sidekiq::Worker

    def perform(undo_release_id, release_id)
      release = Release.find(release_id)
      undo_release = Release.find(undo_release_id)

      existing_changesets = undo_release.changesets.to_a
      matching_changeset = ->(changeset, existing_changesets) do
        existing_changesets.any? do |cs|
          changeset.releasable_type == cs.releasable_type &&
          changeset.releasable_id == cs.releasable
    
    def perform(undo_release_id, release_id)
      release = Release.find(release_id)
      undo_release = Release.find(undo_release_id)

      existing_changesets = undo_release.changesets.to_a
      matching_changeset = ->(changeset, existing_changesets) do
        existing_changesets.any? do |cs|
          changeset.releasable_type == cs.releasable_type &&
          changeset.releasable_id == cs.releasable_id
        end
      end

      release.changesets.each_by(500) do |changeset|
        next if matching_changeset.call(changeset, existing_changesets)
        changeset.build_undo(release: undo_release).save!
      end
    end