Permalink
Browse files

log moderator hat usage

  • Loading branch information...
pushcx committed Oct 25, 2017
1 parent 44c14ae commit bfc8cc0c9d5d49597fd74d2a7c9f7127b405f389
@@ -42,7 +42,7 @@ def index
@moderations = @moderations
.offset((@page - 1) * ENTRIES_PER_PAGE)
.order("moderations.id desc")
.order("moderations.created_at desc")
.limit(ENTRIES_PER_PAGE)
end
end
View
@@ -19,7 +19,7 @@ class Comment < ActiveRecord::Base
end
after_create :record_initial_upvote, :mark_submitter,
:deliver_reply_notifications, :deliver_mention_notifications,
:log_to_countinual
:log_to_countinual, :log_hat_use
after_destroy :unassign_votes
scope :active, -> { where(:is_deleted => false, :is_moderated => false) }
@@ -358,6 +358,17 @@ def is_undeletable_by_user?(user)
end
end
def log_hat_use
return unless self.hat && self.hat.modlog_use
m = Moderation.new
m.created_at = self.created_at
m.comment_id = self.id
m.moderator_user_id = user.id
m.action = "used #{self.hat.hat} hat"
m.save!
end
def log_to_countinual
Countinual.count!("#{Rails.application.shortname}.comments.submitted", "+1")
end
@@ -0,0 +1,6 @@
class ModlogHatUse < ActiveRecord::Migration[5.1]
def change
add_column :hats, :modlog_use, :boolean, :default => false
add_index :moderations, :created_at
end
end
View
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170713195446) do
ActiveRecord::Schema.define(version: 20171025072230) do
create_table "comments", id: :integer, unsigned: true, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
t.datetime "created_at", null: false
@@ -53,6 +53,7 @@
t.integer "granted_by_user_id"
t.string "hat", collation: "utf8mb4_general_ci"
t.string "link", collation: "utf8mb4_general_ci"
t.boolean "modlog_use", default: false
end
create_table "hidden_stories", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
@@ -110,6 +111,7 @@
t.text "action", limit: 16777215
t.text "reason", limit: 16777215
t.boolean "is_from_suggestions", default: false
t.index ["created_at"], name: "index_moderations_on_created_at"
end
create_table "saved_stories", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|

0 comments on commit bfc8cc0

Please sign in to comment.