Sha256: 3e47475f98ad5bb18895f2e78b43b048916d9663e061b0d90b7649e2b36dad37

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

module Tekeya
  module Feed
    module Activity
      module Resque
        # A resque worker to copy activities when an entity tracks another
        class UntrackFeed
          include Tekeya::Feed::Activity::Resque

          @queue = :activity_queue

          # @private
          def self.perform(untracked_feed_key, untracker_feed_key)
            # get the keys to the activities so we can decrement the counters later
            activity_keys = ::Tekeya.redis.zrange(untracked_feed_key, 0, -1)

            ::Tekeya.redis.multi do
              # delete the latest activities of the untracked entity from the tracker feed
              ::Tekeya.redis.zrem(untracker_feed_key, activity_keys)

              # increment the activity counter
              activity_keys.each do |activity_key|
                activity_counter_key = "#{activity_key}:counter"
                ::Tekeya.redis.decr(activity_counter_key)
              end
            end

            # trim the tracker feed and cleanup
            collect_garbage trim_feed(untracker_feed_key)
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tekeya-0.0.7 lib/tekeya/feed/activity/resque/untrack_feed.rb
tekeya-0.0.6 lib/tekeya/feed/activity/resque/untrack_feed.rb
tekeya-0.0.5 lib/tekeya/feed/activity/resque/untrack_feed.rb
tekeya-0.0.4 lib/tekeya/feed/activity/resque/untrack_feed.rb
tekeya-0.0.3 lib/tekeya/feed/activity/resque/untrack_feed.rb
tekeya-0.0.2 lib/tekeya/feed/activity/resque/untrack_feed.rb
tekeya-0.0.1 lib/tekeya/feed/activity/resque/untrack_feed.rb