Class: Thredded::MarkAllRead
- Inherits:
-
Object
- Object
- Thredded::MarkAllRead
- Defined in:
- app/commands/thredded/mark_all_read.rb
Class Method Summary collapse
Class Method Details
.run(user) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/commands/thredded/mark_all_read.rb', line 5 def self.run(user) unread_topics = Thredded::PrivateTopic.unread(user) return if unread_topics.empty? unread_topics.each do |topic| last_post = topic.posts.order_oldest_first.last total_pages = topic.posts.page(1).total_pages Thredded::UserPrivateTopicReadState.touch!( user.id, topic.id, last_post, total_pages ) end end |