2014-11-02 17:57:37 +01:00
|
|
|
class UserController < ApplicationController
|
|
|
|
def show
|
2021-12-30 22:15:59 +01:00
|
|
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).includes(:profile).first!
|
2020-04-20 23:03:57 +02:00
|
|
|
@answers = @user.cursored_answers(last_id: params[:last_id])
|
|
|
|
@answers_last_id = @answers.map(&:id).min
|
|
|
|
@more_data_available = !@user.cursored_answers(last_id: @answers_last_id, size: 1).count.zero?
|
2015-02-10 06:53:50 +01:00
|
|
|
|
|
|
|
if user_signed_in?
|
2021-12-31 22:19:21 +01:00
|
|
|
notif = Notification.where(target_type: "Relationship", target_id: @user.active_follow_relationships.where(target_id: current_user.id).pluck(:id), recipient_id: current_user.id, new: true).first
|
2015-02-10 06:53:50 +01:00
|
|
|
unless notif.nil?
|
|
|
|
notif.new = false
|
|
|
|
notif.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-12-08 15:23:04 +01:00
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
2020-05-09 04:39:09 +02:00
|
|
|
format.js { render layout: false }
|
2014-12-08 15:23:04 +01:00
|
|
|
end
|
2014-11-02 17:57:37 +01:00
|
|
|
end
|
|
|
|
|
2014-12-08 17:03:06 +01:00
|
|
|
def followers
|
|
|
|
@title = 'Followers'
|
2021-12-31 15:35:02 +01:00
|
|
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).includes(:profile).first!
|
2022-06-18 17:29:23 +02:00
|
|
|
@relationships = @user.cursored_follower_relationships(last_id: params[:last_id])
|
|
|
|
@relationships_last_id = @relationships.map(&:id).min
|
|
|
|
@more_data_available = !@user.cursored_follower_relationships(last_id: @relationships_last_id, size: 1).count.zero?
|
|
|
|
@users = @relationships.map(&:source)
|
2014-12-08 19:48:12 +01:00
|
|
|
@type = :friend
|
2020-05-09 04:39:09 +02:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { render "show_follow" }
|
|
|
|
format.js { render "show_follow", layout: false }
|
|
|
|
end
|
2014-12-08 17:03:06 +01:00
|
|
|
end
|
|
|
|
|
2022-01-16 18:51:27 +01:00
|
|
|
# rubocop:disable Metrics/AbcSize
|
2021-12-31 22:19:21 +01:00
|
|
|
def followings
|
2014-12-08 17:03:06 +01:00
|
|
|
@title = 'Following'
|
2021-12-31 15:35:02 +01:00
|
|
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).includes(:profile).first!
|
2022-06-18 17:29:23 +02:00
|
|
|
@relationships = @user.cursored_following_relationships(last_id: params[:last_id])
|
|
|
|
@relationships_last_id = @relationships.map(&:id).min
|
|
|
|
@more_data_available = !@user.cursored_following_relationships(last_id: @relationships_last_id, size: 1).count.zero?
|
|
|
|
@users = @relationships.map(&:target)
|
2014-12-08 19:48:12 +01:00
|
|
|
@type = :friend
|
2020-05-09 04:39:09 +02:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { render "show_follow" }
|
|
|
|
format.js { render "show_follow", layout: false }
|
|
|
|
end
|
2014-12-08 17:03:06 +01:00
|
|
|
end
|
2022-01-16 18:51:27 +01:00
|
|
|
# rubocop:enable Metrics/AbcSize
|
2014-12-19 22:34:24 +01:00
|
|
|
|
|
|
|
def questions
|
|
|
|
@title = 'Questions'
|
2021-12-31 15:35:02 +01:00
|
|
|
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).includes(:profile).first!
|
2020-04-23 03:31:07 +02:00
|
|
|
@questions = @user.cursored_questions(author_is_anonymous: false, last_id: params[:last_id])
|
2020-04-20 23:03:57 +02:00
|
|
|
@questions_last_id = @questions.map(&:id).min
|
2020-04-23 03:31:07 +02:00
|
|
|
@more_data_available = !@user.cursored_questions(author_is_anonymous: false, last_id: @questions_last_id, size: 1).count.zero?
|
2020-05-09 04:39:09 +02:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.js { render layout: false }
|
|
|
|
end
|
2014-12-19 22:34:24 +01:00
|
|
|
end
|
2014-11-02 17:57:37 +01:00
|
|
|
end
|