mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-11 01:05:01 -04:00
Merge pull request #4568 from Growstuff/memory-usage-4
Posts - memory usage
This commit is contained in:
@@ -49,9 +49,10 @@ class Post < ApplicationRecord
|
||||
|
||||
# return posts sorted by recent activity
|
||||
def self.recently_active
|
||||
Post.order(created_at: :desc).sort do |a, b|
|
||||
b.recent_activity <=> a.recent_activity
|
||||
end
|
||||
left_joins(:comments)
|
||||
.select('posts.*, COALESCE(MAX(comments.created_at), posts.created_at) AS last_activity_at')
|
||||
.group('posts.id')
|
||||
.order(Arel.sql('last_activity_at DESC'))
|
||||
end
|
||||
|
||||
def owner_id
|
||||
|
||||
Reference in New Issue
Block a user