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: update_play_data_worker.rb
    path of file: ./repos/plylst/app/workers
    
    the code of the file until where you have to start completion: class UpdatePlayDataWorker
  include Sidekiq::Worker

  sidekiq_options lock: :while_executing, on_conflict: :reject

  def perform(user_id)
    user = User.find user_id

    if user.active?
      ActiveRecord::Base.connecti
    
  def perform(user_id)
    user = User.find user_id

    if user.active?
      ActiveRecord::Base.connection.exec_query("UPDATE follows 
        SET plays = s.plays, last_played_at = s.last 
        FROM (
          SELECT 
            track_id, 
            count(1) as plays, 
            max(played_at) as last 
          FROM streams 
          WHERE user_id = #{user.id}
          GROUP BY track_id
        ) s 
        WHERE s.track_id = follows.track_id 
          AND follows.user_id = #{user.id}")
    end