trendable 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/concerns/trendable.rb +1 -1
- data/lib/trendable/version.rb +1 -1
- data/lib/workers/fade_out_trend_power_worker.rb +4 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32ecf8010770ec345054ea87407d863e5f4966d9
|
4
|
+
data.tar.gz: 7ffbd65da9234dd1bf102b6bb86952785a1118c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56a8f3a7d12d86fc23b55a28c92e0830c7039d1b5d22ae0bdb898d3ff168d605125ed3ebc34a88cd8f41d3a0924f368b45c1e745ec90b569ebd335a2be3df9ea
|
7
|
+
data.tar.gz: d5148efd4cea79d4c0832336f19d3393c5983dcdfb7c560353b1eda2f7a21b17537ddc5477d521f4a1fcd692ebaaec17b0ea2aba83ea81053f5200f89650a805
|
data/lib/concerns/trendable.rb
CHANGED
@@ -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, -> {
|
7
|
+
scope :items_to_fade_trending_power, -> { where( "trending_power > 0" ) }
|
8
8
|
|
9
9
|
def self.has_trendable_concern?
|
10
10
|
true
|
data/lib/trendable/version.rb
CHANGED
@@ -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.
|
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
|