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 :subscriptions, dependent: :destroy
|
||||||
has_many :comment_smiles, through: :comments, source: :smiles
|
has_many :comment_smiles, through: :comments, source: :smiles
|
||||||
|
|
||||||
|
# rubocop:disable Rails/SkipsModelValidations
|
||||||
after_create do
|
after_create do
|
||||||
Inbox.where(user: self.user, question: self.question).destroy_all
|
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?
|
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.user, self
|
||||||
Subscription.subscribe self.question.user, self unless self.question.author_is_anonymous
|
Subscription.subscribe self.question.user, self unless self.question.author_is_anonymous
|
||||||
self.user.increment! :answered_count
|
user.increment! :answered_count
|
||||||
self.question.increment! :answer_count
|
question.increment! :answer_count
|
||||||
end
|
end
|
||||||
|
|
||||||
before_destroy do
|
before_destroy do
|
||||||
|
@ -28,8 +29,8 @@ class Answer < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.user&.decrement! :answered_count
|
user&.decrement! :answered_count
|
||||||
self.question&.decrement! :answer_count
|
question&.decrement! :answer_count
|
||||||
self.smiles.each do |smile|
|
self.smiles.each do |smile|
|
||||||
Notification.denotify self.user, smile
|
Notification.denotify self.user, smile
|
||||||
end
|
end
|
||||||
|
@ -40,6 +41,7 @@ class Answer < ApplicationRecord
|
||||||
Notification.denotify self.question.user, self
|
Notification.denotify self.question.user, self
|
||||||
Subscription.destruct self
|
Subscription.destruct self
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Rails/SkipsModelValidations
|
||||||
|
|
||||||
def notification_type(*_args)
|
def notification_type(*_args)
|
||||||
Notifications::QuestionAnswered
|
Notifications::QuestionAnswered
|
||||||
|
|
|
@ -7,6 +7,7 @@ class Comment < ApplicationRecord
|
||||||
|
|
||||||
validates :content, length: { maximum: 160 }
|
validates :content, length: { maximum: 160 }
|
||||||
|
|
||||||
|
# rubocop:disable Rails/SkipsModelValidations
|
||||||
after_create do
|
after_create do
|
||||||
Subscription.subscribe self.user, answer, false
|
Subscription.subscribe self.user, answer, false
|
||||||
Subscription.notify self, answer
|
Subscription.notify self, answer
|
||||||
|
@ -24,9 +25,10 @@ class Comment < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
Subscription.denotify self, answer
|
Subscription.denotify self, answer
|
||||||
user&.decrement! :commented_count
|
user&.decrement! :commented_count
|
||||||
answer&.decrement! :comment_count
|
answer&.decrement! :comment_count
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Rails/SkipsModelValidations
|
||||||
|
|
||||||
def notification_type(*_args)
|
def notification_type(*_args)
|
||||||
Notifications::Commented
|
Notifications::Commented
|
||||||
|
|
|
@ -16,7 +16,9 @@ class Question < ApplicationRecord
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
def can_be_removed?
|
def can_be_removed?
|
||||||
|
|
Loading…
Reference in New Issue