Added related content one positive score by default on create
This commit is contained in:
@@ -13,7 +13,6 @@ class RelatedContent < ActiveRecord::Base
|
|||||||
validates :parent_relationable_id, uniqueness: { scope: [:parent_relationable_type, :child_relationable_id, :child_relationable_type] }
|
validates :parent_relationable_id, uniqueness: { scope: [:parent_relationable_type, :child_relationable_id, :child_relationable_type] }
|
||||||
|
|
||||||
after_create :create_opposite_related_content, unless: proc { opposite_related_content.present? }
|
after_create :create_opposite_related_content, unless: proc { opposite_related_content.present? }
|
||||||
after_destroy :destroy_opposite_related_content, if: proc { opposite_related_content.present? }
|
|
||||||
|
|
||||||
scope :not_hidden, -> { where('positive_score - negative_score / LEAST(nullif(positive_score + negative_score, 0), 1) >= ?', RELATED_CONTENTS_REPORT_THRESHOLD) }
|
scope :not_hidden, -> { where('positive_score - negative_score / LEAST(nullif(positive_score + negative_score, 0), 1) >= ?', RELATED_CONTENTS_REPORT_THRESHOLD) }
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class AddRelatedContentsPositiveAndNegativeScore < ActiveRecord::Migration
|
|||||||
def change
|
def change
|
||||||
remove_column :related_contents, :flags_count
|
remove_column :related_contents, :flags_count
|
||||||
|
|
||||||
add_column :related_contents, :positive_score, :integer, default: 0
|
add_column :related_contents, :positive_score, :integer, default: 1
|
||||||
add_column :related_contents, :negative_score, :integer, default: 0
|
add_column :related_contents, :negative_score, :integer, default: 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user