Class: Pageflow::CommentThreadRead Private

Inherits:
ApplicationRecord show all
Defined in:
app/models/pageflow/comment_thread_read.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Records when a user last read a comment thread. Keyed by perma id so read state survives comment threads being copied to a new revision.

API:

  • private

Class Method Summary collapse

Class Method Details

.mark(entry:, user:, comment_thread_perma_ids:, read_at: Time.current) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



15
16
17
18
19
20
# File 'app/models/pageflow/comment_thread_read.rb', line 15

def self.mark(entry:, user:, comment_thread_perma_ids:, read_at: Time.current)
  comment_thread_perma_ids.each do |perma_id|
    find_or_initialize_by(entry:, user:, comment_thread_perma_id: perma_id)
      .update!(read_at:)
  end
end

.read_at_by_perma_id(entry:, user:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



11
12
13
# File 'app/models/pageflow/comment_thread_read.rb', line 11

def self.read_at_by_perma_id(entry:, user:)
  where(entry:, user:).pluck(:comment_thread_perma_id, :read_at).to_h
end