Sha256: ef4dccba8eb5676503a01969b811f0bc4d2aa754f88bcfe4c3b21cf4e8666ed7

Contents?: true

Size: 512 Bytes

Versions: 16

Compression:

Stored size: 512 Bytes

Contents

class CountPublisher
  INCREMENT_SIZE = 1000

  def initialize(redis_row_count)
    @redis_row_count = redis_row_count
    @redis = Redis.current
  end

  def callbacks
    { during_execute: publish_ongoing, after_execute: expire_count }
  end

  private

  def publish_ongoing
    lambda do |_row, row_count|
      if row_count % INCREMENT_SIZE == 0
        @redis_row_count.increment_count_by(INCREMENT_SIZE)
      end
    end
  end

  def expire_count
    ->(_row_count) { @redis_row_count.expire }
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
aleph_analytics-0.4.9.pre.dev lib/count_publisher.rb
aleph_analytics-0.4.8 lib/count_publisher.rb
aleph_analytics-0.4.7 lib/count_publisher.rb
aleph_analytics-0.4.4 lib/count_publisher.rb
aleph_analytics-0.4.2 lib/count_publisher.rb
aleph_analytics-0.4.1 lib/count_publisher.rb
aleph_analytics-0.3.0 lib/count_publisher.rb
aleph_analytics-0.2.0 lib/count_publisher.rb
aleph_analytics-0.1.0 lib/count_publisher.rb
aleph_analytics-0.0.6 lib/count_publisher.rb
aleph_analytics-0.0.5 lib/count_publisher.rb
aleph_analytics-0.0.4 lib/count_publisher.rb
aleph_analytics-0.0.3 lib/count_publisher.rb
aleph_analytics-0.0.2 lib/count_publisher.rb
aleph_analytics-0.0.1.alpha lib/count_publisher.rb
aleph_analytics-0.0.0.alpha lib/count_publisher.rb