2020-04-20 14:03:57 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module User::QuestionMethods
|
|
|
|
include CursorPaginatable
|
|
|
|
|
|
|
|
define_cursor_paginator :cursored_questions, :ordered_questions
|
|
|
|
|
2023-01-28 12:17:25 -08:00
|
|
|
# @return [ActiveRecord::Relation<Question>] List of questions sent by the user
|
2022-07-24 12:56:03 -07:00
|
|
|
def ordered_questions(author_is_anonymous: nil, direct: nil)
|
2020-04-20 14:03:57 -07:00
|
|
|
questions
|
2022-07-24 13:27:15 -07:00
|
|
|
.where({ author_is_anonymous:, direct: }.compact)
|
2020-04-20 14:03:57 -07:00
|
|
|
.order(:created_at)
|
|
|
|
.reverse_order
|
|
|
|
end
|
|
|
|
end
|