@ -16,22 +16,10 @@ class Follow < ActiveRecord::Base
end
defobject_type
target.object_type
end
defcontent
self.destroyed??"#{self.account.acct} is no longer following #{self.target_account.acct}":"#{self.account.acct} started following #{self.target_account.acct}"
self.destroyed??"#{self.account.acct} is no longer following #{self.target_account.acct}":"#{self.account.acct} started following #{self.target_account.acct}"
scope:with_counters,->{select('statuses.*, (select count(r.id) from statuses as r where r.reblog_of_id = statuses.id) as reblogs_count, (select count(f.id) from favourites as f where f.status_id = statuses.id) as favourites_count')}
Status.where(id:Status.find_by_sql(['WITH RECURSIVE search_tree(id, in_reply_to_id, path) AS (SELECT id, in_reply_to_id, ARRAY[id] FROM statuses WHERE id = ? UNION ALL SELECT statuses.id, statuses.in_reply_to_id, path || statuses.id FROM search_tree JOIN statuses ON statuses.id = search_tree.in_reply_to_id WHERE NOT statuses.id = ANY(path)) SELECT id FROM search_tree ORDER BY path DESC',self.id])-[self])
end
@ -80,7 +67,11 @@ class Status < ActiveRecord::Base
Status.where(id:Status.find_by_sql(['WITH RECURSIVE search_tree(id, path) AS (SELECT id, ARRAY[id] FROM statuses WHERE id = ? UNION ALL SELECT statuses.id, path || statuses.id FROM search_tree JOIN statuses ON statuses.in_reply_to_id = search_tree.id WHERE NOT statuses.id = ANY(path)) SELECT id FROM search_tree ORDER BY path',self.id])-[self])