Fix lints

This commit is contained in:
Andreas Nedbal 2022-11-15 21:41:05 +01:00 committed by Andreas Nedbal
parent 92d5918b91
commit fe9a77cd67
2 changed files with 11 additions and 9 deletions

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class UserController < ApplicationController class UserController < ApplicationController
before_action :set_user before_action :set_user
before_action :hidden_social_graph_redirect, only: %i[followers followings] before_action :hidden_social_graph_redirect, only: %i[followers followings]
@ -22,7 +24,7 @@ class UserController < ApplicationController
end end
def followers def followers
@title = 'Followers' @title = "Followers"
@relationships = @user.cursored_follower_relationships(last_id: params[:last_id]) @relationships = @user.cursored_follower_relationships(last_id: params[:last_id])
@relationships_last_id = @relationships.map(&:id).min @relationships_last_id = @relationships.map(&:id).min
@more_data_available = !@user.cursored_follower_relationships(last_id: @relationships_last_id, size: 1).count.zero? @more_data_available = !@user.cursored_follower_relationships(last_id: @relationships_last_id, size: 1).count.zero?
@ -35,9 +37,8 @@ class UserController < ApplicationController
end end
end end
# rubocop:disable Metrics/AbcSize
def followings def followings
@title = 'Following' @title = "Following"
@relationships = @user.cursored_following_relationships(last_id: params[:last_id]) @relationships = @user.cursored_following_relationships(last_id: params[:last_id])
@relationships_last_id = @relationships.map(&:id).min @relationships_last_id = @relationships.map(&:id).min
@more_data_available = !@user.cursored_following_relationships(last_id: @relationships_last_id, size: 1).count.zero? @more_data_available = !@user.cursored_following_relationships(last_id: @relationships_last_id, size: 1).count.zero?
@ -49,10 +50,9 @@ class UserController < ApplicationController
format.turbo_stream { render "show_follow" } format.turbo_stream { render "show_follow" }
end end
end end
# rubocop:enable Metrics/AbcSize
def questions def questions
@title = 'Questions' @title = "Questions"
@questions = @user.cursored_questions(author_is_anonymous: false, direct: belongs_to_current_user? || moderation_view?, last_id: params[:last_id]) @questions = @user.cursored_questions(author_is_anonymous: false, direct: belongs_to_current_user? || moderation_view?, 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, direct: belongs_to_current_user? || moderation_view?, last_id: @questions_last_id, size: 1).count.zero? @more_data_available = !@user.cursored_questions(author_is_anonymous: false, direct: belongs_to_current_user? || moderation_view?, last_id: @questions_last_id, size: 1).count.zero?
@ -66,13 +66,13 @@ class UserController < ApplicationController
private private
def set_user def set_user
@user = User.where('LOWER(screen_name) = ?', params[:username].downcase).includes(:profile).first! @user = User.where("LOWER(screen_name) = ?", params[:username].downcase).includes(:profile).first!
end end
def hidden_social_graph_redirect def hidden_social_graph_redirect
unless belongs_to_current_user? || !@user.privacy_hide_social_graph return if belongs_to_current_user? || !@user.privacy_hide_social_graph
redirect_to user_path(@user)
end redirect_to user_path(@user)
end end
def belongs_to_current_user? = @user == current_user def belongs_to_current_user? = @user == current_user

View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
class AddPrivacyHideSocialGraph < ActiveRecord::Migration[6.1] class AddPrivacyHideSocialGraph < ActiveRecord::Migration[6.1]
def up def up
add_column :users, :privacy_hide_social_graph, :boolean, default: false add_column :users, :privacy_hide_social_graph, :boolean, default: false