feat: Show last non-activity messages in the chat list (#5864)

This commit is contained in:
Pranav Raj S
2022-11-16 15:43:55 -08:00
committed by GitHub
parent 9b9c019de0
commit 66044a0dc3
6 changed files with 134 additions and 34 deletions

View File

@@ -73,6 +73,7 @@ class Message < ApplicationRecord
# .succ is a hack to avoid https://makandracards.com/makandra/1057-why-two-ruby-time-objects-are-not-equal-although-they-appear-to-be
scope :unread_since, ->(datetime) { where('EXTRACT(EPOCH FROM created_at) > (?)', datetime.to_i.succ) }
scope :chat, -> { where.not(message_type: :activity).where(private: false) }
scope :non_activity_messages, -> { where.not(message_type: :activity).reorder('id desc') }
scope :today, -> { where("date_trunc('day', created_at) = ?", Date.current) }
default_scope { order(created_at: :asc) }