mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-02 21:20:08 +08:00
Fix sorting of results by newest/oldest (by updated_at) [SCI-7118]
This commit is contained in:
parent
13b085bc9d
commit
194963a94e
1 changed files with 5 additions and 1 deletions
|
@ -52,7 +52,11 @@ class Comment < ApplicationRecord
|
||||||
def self.mark_as_seen_by(user, commentable)
|
def self.mark_as_seen_by(user, commentable)
|
||||||
# rubocop:disable Rails/SkipsModelValidations
|
# rubocop:disable Rails/SkipsModelValidations
|
||||||
all.where('? = ANY (unseen_by)', user.id).update_all("unseen_by = array_remove(unseen_by, #{user.id.to_i}::bigint)")
|
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
|
# rubocop:enable Rails/SkipsModelValidations
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue