Fix user questions page

This commit is contained in:
Georg Gadinger 2020-04-23 03:31:07 +02:00
parent a8c335899d
commit 445d9ebe2a
2 changed files with 4 additions and 3 deletions

View File

@ -94,9 +94,9 @@ class UserController < ApplicationController
def questions
@title = 'Questions'
@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
@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
def data

View File

@ -5,8 +5,9 @@ module User::QuestionMethods
define_cursor_paginator :cursored_questions, :ordered_questions
def ordered_questions
def ordered_questions(author_is_anonymous: nil)
questions
.where({ author_is_anonymous: author_is_anonymous }.compact)
.order(:created_at)
.reverse_order
end