virgo 0.1.16 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/virgo/post.rb +14 -18
- data/lib/virgo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 580bd7bd217b956832844c3f3f3f76dd843af6a9
|
4
|
+
data.tar.gz: 5fc73ea9fd9ca9e38407adb167df994f0372903d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 390057353037d414a40cb18f8778c131a22695287e7d93776d00653b254c24c5b82c96a21166171447ed8ed1e833550599f1cb1c5198a04d678a6460db97c7d4
|
7
|
+
data.tar.gz: e110457925f20ad0ff9b4f85174cd3ab6a0f1dffe27f20bb3c87b0f885b2bbfd9a1c2380feaafb0510c54dcf9f8297f560a0a912506ae9749571d72b05249b2c
|
data/app/models/virgo/post.rb
CHANGED
@@ -213,29 +213,25 @@ module Virgo
|
|
213
213
|
def track_view!
|
214
214
|
update_columns({
|
215
215
|
view_count: (view_count + 1),
|
216
|
-
popularity: calc_popularity
|
216
|
+
popularity: calc_popularity
|
217
217
|
})
|
218
218
|
end
|
219
219
|
|
220
|
-
|
220
|
+
# based on reddit "hot" algorithm:
|
221
|
+
# https://gist.github.com/jrochkind/2636355
|
222
|
+
def calc_popularity
|
221
223
|
unless publish_at.nil?
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
# age factor is a number in the range of 0.1 - 1.00
|
233
|
-
# that is used to moderate the weight of votes for this post
|
234
|
-
age_factor = 0.1 + (0.9*age_percentage)
|
235
|
-
|
236
|
-
basis = opt == :increment ? (view_count + 1) : view_count
|
224
|
+
s = view_count
|
225
|
+
displacement = Math.log( [s.abs, 1].max, 10 )
|
226
|
+
sign = if s > 0
|
227
|
+
1
|
228
|
+
elsif s < 0
|
229
|
+
-1
|
230
|
+
else
|
231
|
+
0
|
232
|
+
end
|
237
233
|
|
238
|
-
|
234
|
+
rank = (displacement * sign.to_f) + ( epoch_seconds(publish_at) / 45000 )
|
239
235
|
else
|
240
236
|
0
|
241
237
|
end
|
data/lib/virgo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: virgo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Zaillian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|