Appease the dog overlords
These counters are legacy and will later be removed.
This commit is contained in:
parent
539505eccd
commit
8a6a9c21ec
|
@ -8,14 +8,15 @@ class Answer < ApplicationRecord
|
|||
has_many :subscriptions, dependent: :destroy
|
||||
has_many :comment_smiles, through: :comments, source: :smiles
|
||||
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
after_create do
|
||||
Inbox.where(user: self.user, question: self.question).destroy_all
|
||||
|
||||
Notification.notify self.question.user, self unless self.question.user == self.user or self.question.user.nil?
|
||||
Subscription.subscribe self.user, self
|
||||
Subscription.subscribe self.question.user, self unless self.question.author_is_anonymous
|
||||
self.user.increment! :answered_count
|
||||
self.question.increment! :answer_count
|
||||
user.increment! :answered_count
|
||||
question.increment! :answer_count
|
||||
end
|
||||
|
||||
before_destroy do
|
||||
|
@ -28,8 +29,8 @@ class Answer < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
self.user&.decrement! :answered_count
|
||||
self.question&.decrement! :answer_count
|
||||
user&.decrement! :answered_count
|
||||
question&.decrement! :answer_count
|
||||
self.smiles.each do |smile|
|
||||
Notification.denotify self.user, smile
|
||||
end
|
||||
|
@ -40,6 +41,7 @@ class Answer < ApplicationRecord
|
|||
Notification.denotify self.question.user, self
|
||||
Subscription.destruct self
|
||||
end
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
|
||||
def notification_type(*_args)
|
||||
Notifications::QuestionAnswered
|
||||
|
|
|
@ -7,6 +7,7 @@ class Comment < ApplicationRecord
|
|||
|
||||
validates :content, length: { maximum: 160 }
|
||||
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
after_create do
|
||||
Subscription.subscribe self.user, answer, false
|
||||
Subscription.notify self, answer
|
||||
|
@ -24,9 +25,10 @@ class Comment < ApplicationRecord
|
|||
end
|
||||
|
||||
Subscription.denotify self, answer
|
||||
user&.decrement! :commented_count
|
||||
user&.decrement! :commented_count
|
||||
answer&.decrement! :comment_count
|
||||
end
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
|
||||
def notification_type(*_args)
|
||||
Notifications::Commented
|
||||
|
|
|
@ -16,7 +16,9 @@ class Question < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
user&.decrement! :asked_count unless self.author_is_anonymous
|
||||
# rubocop:disable Rails/SkipsModelValidations
|
||||
user&.decrement! :asked_count unless author_is_anonymous
|
||||
# rubocop:enable Rails/SkipsModelValidations
|
||||
end
|
||||
|
||||
def can_be_removed?
|
||||
|
|
Loading…
Reference in New Issue