trendable 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e33b5f509a93d24c5c1d0dc5facb22c2645f3b0a
4
- data.tar.gz: 2c2bc2297ffe8e25c39e2c5adb8984335360a1e5
3
+ metadata.gz: 32ecf8010770ec345054ea87407d863e5f4966d9
4
+ data.tar.gz: 7ffbd65da9234dd1bf102b6bb86952785a1118c9
5
5
  SHA512:
6
- metadata.gz: 2ac267a08e54525dc3fd0c8d714c419c782c3a226f5c20aee4a2346685a1ea4a83b6e7fcd626cf067e2c80c0f5ee2caf3c69b887905551aea3603ded06b6706f
7
- data.tar.gz: 5ab690225845da9bcde22de113c589cad3e95c80b59f1258eb66096112ae6c60e0386deaed144ad32abd78345e845fbdaa9bd3b686ceee45ddb5c100377c1b7a
6
+ metadata.gz: 56a8f3a7d12d86fc23b55a28c92e0830c7039d1b5d22ae0bdb898d3ff168d605125ed3ebc34a88cd8f41d3a0924f368b45c1e745ec90b569ebd335a2be3df9ea
7
+ data.tar.gz: d5148efd4cea79d4c0832336f19d3393c5983dcdfb7c560353b1eda2f7a21b17537ddc5477d521f4a1fcd692ebaaec17b0ea2aba83ea81053f5200f89650a805
@@ -4,7 +4,7 @@ module Trendable
4
4
 
5
5
  included do
6
6
  scope :order_by_trending, -> { order( trending_power: :desc ) }
7
- scope :items_to_fade_trending_power, -> { all }
7
+ scope :items_to_fade_trending_power, -> { where( "trending_power > 0" ) }
8
8
 
9
9
  def self.has_trendable_concern?
10
10
  true
@@ -1,5 +1,5 @@
1
1
  module Trendable
2
2
  module Rails
3
- VERSION = "1.2.1"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  end
@@ -1,13 +1,15 @@
1
1
  class FadeOutTrendPowerWorker
2
2
  include Sidekiq::Worker
3
3
 
4
- def perform( multiplier = 0.9 )
4
+ def perform( multiplier = 0.9, batch_size = 1000 )
5
5
  Rails.application.eager_load! if Rails.env.development?
6
6
 
7
7
  ActiveRecord::Base.descendants.each do |klass|
8
8
  if klass.respond_to?( "has_trendable_concern?".to_sym )
9
9
 
10
- klass.items_to_fade_trending_power.update_all( "trending_power = trending_power * #{multiplier}")
10
+ klass.items_to_fade_trending_power.find_in_batches( batch_size: batch_size ) do |batch|
11
+ batch.update_all( "trending_power = trending_power * #{multiplier}")
12
+ end
11
13
  else
12
14
  puts "#{klass.to_s} does not have trendable concern"
13
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trendable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff McFadden