add per-tag story hotness modifiers
This commit is contained in:
parent
e252d2d66e
commit
962b7e8d59
|
@ -128,8 +128,13 @@ class Story < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def calculated_hotness
|
||||
base = 10
|
||||
self.tags.select{|t| t.hotness_mod != 0 }.each do |t|
|
||||
base -= t.hotness_mod
|
||||
end
|
||||
|
||||
# don't immediately kill stories at 0 by bumping up score by one
|
||||
order = Math.log([ (score + 1).abs + comments_count, 1 ].max, 10)
|
||||
order = Math.log([ (score + 1).abs + comments_count, 1 ].max, base)
|
||||
if score > 0
|
||||
sign = 1
|
||||
elsif score < 0
|
||||
|
|
5
db/migrate/20140825225915_add_tag_hotness_mod.rb
Normal file
5
db/migrate/20140825225915_add_tag_hotness_mod.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddTagHotnessMod < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :tags, :hotness_mod, :integer, :default => 0
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140804005415) do
|
||||
ActiveRecord::Schema.define(version: 20140825225915) do
|
||||
|
||||
create_table "comments", force: true do |t|
|
||||
t.datetime "created_at", null: false
|
||||
|
@ -134,6 +134,7 @@ ActiveRecord::Schema.define(version: 20140804005415) do
|
|||
t.boolean "privileged", default: false
|
||||
t.boolean "is_media", default: false
|
||||
t.boolean "inactive", default: false
|
||||
t.integer "hotness_mod", default: 0
|
||||
end
|
||||
|
||||
add_index "tags", ["tag"], name: "tag", unique: true, using: :btree
|
||||
|
|
Loading…
Reference in a new issue