Sha256: 8e63622721600f04a73b131d34fc7bbe09e0ee5088f87d667fe9217a0360a04a

Contents?: true

Size: 880 Bytes

Versions: 24

Compression:

Stored size: 880 Bytes

Contents

# frozen_string_literal: true

module Thredded
  class ActivityUpdaterJob < ::ActiveJob::Base
    queue_as :default

    def perform(user_id, messageboard_id)
      now = Time.current

      begin
        user_detail = Thredded::UserDetail.find_or_initialize_by(user_id: user_id)
        user_detail.update!(last_seen_at: now)
      rescue ActiveRecord::RecordNotUnique
        # The record has been created from another connection, retry to find it.
        retry
      end

      begin
        Thredded::MessageboardUser
          .find_or_initialize_by(
            thredded_messageboard_id: messageboard_id,
            thredded_user_detail_id: user_detail.id
          )
          .update!(last_seen_at: now)
      rescue ActiveRecord::RecordNotUnique
        # The record has been created from another connection, retry to find it.
        retry
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
thredded-1.1.0 app/jobs/thredded/activity_updater_job.rb
thredded-1.0.1 app/jobs/thredded/activity_updater_job.rb
thredded-1.0.0 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.16 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.15 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.14 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.13 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.12 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.11 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.10 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.9 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.8 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.7 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.6 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.5 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.4 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.3 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.1 app/jobs/thredded/activity_updater_job.rb
thredded-0.16.0 app/jobs/thredded/activity_updater_job.rb
thredded-0.15.5 app/jobs/thredded/activity_updater_job.rb