Fix sorting of results by newest/oldest (by updated_at) [SCI-7118]

This commit is contained in:
Martin Artnik 2022-08-30 11:48:09 +02:00
parent 13b085bc9d
commit 194963a94e

View file

@ -52,7 +52,11 @@ class Comment < ApplicationRecord
def self.mark_as_seen_by(user, commentable)
# rubocop:disable Rails/SkipsModelValidations
all.where('? = ANY (unseen_by)', user.id).update_all("unseen_by = array_remove(unseen_by, #{user.id.to_i}::bigint)")
commentable.touch
# Because we want the number of unseen comments to affect the cache of project
# and experiment lists, we need to set the updated_at of Project or Experiment.
commentable.touch if commentable.class.in? [Project, Experiment]
# rubocop:enable Rails/SkipsModelValidations
end
end