2020-04-20 14:03:57 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module User::TimelineMethods
|
|
|
|
include CursorPaginatable
|
|
|
|
|
|
|
|
define_cursor_paginator :cursored_timeline, :timeline
|
|
|
|
|
2023-01-28 12:17:08 -08:00
|
|
|
# @return [ActiveRecord::Relation<Answer>] the user's timeline
|
2020-04-20 14:03:57 -07:00
|
|
|
def timeline
|
2023-01-28 12:17:08 -08:00
|
|
|
Answer
|
|
|
|
.where("user_id in (?) OR user_id = ?", following_ids, id)
|
|
|
|
.order(:created_at)
|
|
|
|
.reverse_order
|
|
|
|
.includes(comments: %i[user smiles], question: { user: :profile }, user: [:profile], smiles: [:user])
|
2020-04-20 14:03:57 -07:00
|
|
|
end
|
|
|
|
end
|