retrospring/app/models/user/question_methods.rb

16 lines
428 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module User::QuestionMethods
include CursorPaginatable
define_cursor_paginator :cursored_questions, :ordered_questions
2023-01-28 21:17:25 +01:00
# @return [ActiveRecord::Relation<Question>] List of questions sent by the user
def ordered_questions(author_is_anonymous: nil, direct: nil)
questions
2022-07-24 22:27:15 +02:00
.where({ author_is_anonymous:, direct: }.compact)
.order(:created_at)
.reverse_order
end
end