Don't list direct questions on user profiles

This commit is contained in:
Andreas Nedbal 2022-07-24 21:56:03 +02:00
parent 70e95375fb
commit 83dbd5d2e3
3 changed files with 5 additions and 4 deletions

View File

@ -54,7 +54,7 @@ class UserController < ApplicationController
def questions def questions
@title = 'Questions' @title = 'Questions'
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).includes(:profile).first! @user = User.where('LOWER(screen_name) = ?', params[:username].downcase).includes(:profile).first!
@questions = @user.cursored_questions(author_is_anonymous: false, last_id: params[:last_id]) @questions = @user.cursored_questions(author_is_anonymous: false, direct: 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(author_is_anonymous: false, 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?

View File

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

View File

@ -20,7 +20,8 @@ module UseCase
content: content, content: content,
author_is_anonymous: anonymous, author_is_anonymous: anonymous,
author_identifier: author_identifier, author_identifier: author_identifier,
user: source_user_id.nil? ? nil : source_user user: source_user_id.nil? ? nil : source_user,
direct: true
) )
return if filtered?(question) return if filtered?(question)