2020-04-20 14:03:57 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module User::AnswerMethods
|
|
|
|
include CursorPaginatable
|
|
|
|
|
|
|
|
define_cursor_paginator :cursored_answers, :ordered_answers
|
|
|
|
|
2023-01-28 12:17:08 -08:00
|
|
|
# @return [ActiveRecord::Relation<Answer>] List of a user's answers
|
2023-11-26 10:32:50 -08:00
|
|
|
def ordered_answers(current_user_id:)
|
2020-04-20 14:03:57 -07:00
|
|
|
answers
|
2023-11-26 10:32:50 -08:00
|
|
|
.for_user(current_user_id)
|
2020-04-20 14:03:57 -07:00
|
|
|
.order(:created_at)
|
|
|
|
.reverse_order
|
2023-10-22 12:51:21 -07:00
|
|
|
.includes(question: { user: [:profile] })
|
2020-04-20 14:03:57 -07:00
|
|
|
end
|
|
|
|
end
|