Fix user questions page
This commit is contained in:
parent
a8c335899d
commit
445d9ebe2a
|
@ -94,9 +94,9 @@ class UserController < ApplicationController
|
||||||
def questions
|
def questions
|
||||||
@title = 'Questions'
|
@title = 'Questions'
|
||||||
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).first!
|
||||||
@questions = @user.cursored_questions(last_id: params[:last_id])
|
@questions = @user.cursored_questions(author_is_anonymous: false, last_id: params[:last_id])
|
||||||
@questions_last_id = @questions.map(&:id).min
|
@questions_last_id = @questions.map(&:id).min
|
||||||
@more_data_available = !@user.cursored_questions(last_id: @questions_last_id, size: 1).count.zero?
|
@more_data_available = !@user.cursored_questions(author_is_anonymous: false, last_id: @questions_last_id, size: 1).count.zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
def data
|
def data
|
||||||
|
|
|
@ -5,8 +5,9 @@ module User::QuestionMethods
|
||||||
|
|
||||||
define_cursor_paginator :cursored_questions, :ordered_questions
|
define_cursor_paginator :cursored_questions, :ordered_questions
|
||||||
|
|
||||||
def ordered_questions
|
def ordered_questions(author_is_anonymous: nil)
|
||||||
questions
|
questions
|
||||||
|
.where({ author_is_anonymous: author_is_anonymous }.compact)
|
||||||
.order(:created_at)
|
.order(:created_at)
|
||||||
.reverse_order
|
.reverse_order
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue