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: template_render_job.rb
    path of file: ./repos/foreman/app/jobs
    
    the code of the file until where you have to start completion: class TemplateRenderJob < ApplicationJob
  queue_as :default
  include ::Foreman::ObservableJob
  set_hook :template_render_performed

  def perform(composer_params, opts = {})
    user = User.unscoped.f
    
  def perform(composer_params, opts = {})
    user = User.unscoped.find(opts[:user_id])
    composer_params['gzip'] = opts[:gzip].nil? ? !!composer_params['gzip'] : opts[:gzip]
    User.as user.login do
      composer = ReportComposer.new(composer_params)
      start_time = Time.now
      result = composer.render
      end_time = Time.now
      if composer.send_mail?
        ReportMailer.report(composer_params, result, start: start_time, end: end_time).deliver_now
      else
        StoredValue.write(provider_job_id, result, expire_at: Time.now + 1.day)
        UINotifications::ReportFinished.new(composer, provider_job_id).deliver!
      end
    end