From 6e4fff0393f6630c0922ca751a07a4695dbca41e Mon Sep 17 00:00:00 2001 From: Kaio Magalhaes Date: Thu, 5 Dec 2024 16:16:07 -0300 Subject: [PATCH] fix only_internal users --- .rubocop_todo.yml | 26 +++++++++---------- Gemfile.lock | 3 +++ .../analytics/skills_controller.rb | 2 +- app/controllers/users_controller.rb | 3 +++ 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a24ca54..17744ef 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-07-01 18:59:17 UTC using RuboCop version 1.56.2. +# on 2024-12-05 19:15:44 UTC using RuboCop version 1.56.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -12,27 +12,26 @@ Lint/MissingSuper: Exclude: - 'app/services/time_off_builder.rb' -# Offense count: 10 +# Offense count: 11 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 34 -# Offense count: 1 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. -# AllowedMethods: refine -Metrics/BlockLength: - Max: 27 - -# Offense count: 1 +# Offense count: 2 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: - Max: 8 + Max: 9 -# Offense count: 16 +# Offense count: 18 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Max: 23 +# Offense count: 1 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/PerceivedComplexity: + Max: 10 + # Offense count: 1 # Configuration parameters: Include. # Include: app/controllers/**/*.rb, app/mailers/**/*.rb @@ -53,17 +52,16 @@ Security/Eval: Exclude: - 'app/models/dynamic_dataset.rb' -# Offense count: 5 +# Offense count: 4 # Configuration parameters: AllowedMethods. # AllowedMethods: respond_to_missing? Style/OptionalBooleanParameter: Exclude: - 'app/models/concerns/calculable.rb' - 'app/models/maintenance_contract_model.rb' - - 'app/models/retainer_contract_model.rb' - 'app/utils/analytics/finances/models/financial_statements_of_work.rb' -# Offense count: 12 +# Offense count: 14 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https diff --git a/Gemfile.lock b/Gemfile.lock index bb6ab85..5be8fe1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -167,6 +167,8 @@ GEM nio4r (2.5.9) nokogiri (1.15.4-aarch64-linux) racc (~> 1.4) + nokogiri (1.15.4-arm64-darwin) + racc (~> 1.4) nokogiri (1.15.4-x86_64-linux) racc (~> 1.4) parallel (1.23.0) @@ -319,6 +321,7 @@ GEM PLATFORMS aarch64-linux + arm64-darwin-23 x86_64-linux DEPENDENCIES diff --git a/app/controllers/analytics/skills_controller.rb b/app/controllers/analytics/skills_controller.rb index af37488..c1cec54 100644 --- a/app/controllers/analytics/skills_controller.rb +++ b/app/controllers/analytics/skills_controller.rb @@ -11,7 +11,7 @@ def index private def search_skills - return Skill.all unless params[:search].present? + return Skill.all if params[:search].blank? Skill.where('name ILIKE ?', "%#{params[:search]}%") end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 94d94e3..4e1ec4d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -6,6 +6,7 @@ class UsersController < ApplicationController def index query = params['query']&.split(',') skills_filter = params['filter_by_skills']&.split(/[\s,]+/)&.map(&:downcase) + only_internal = params['only_internal'] @users = if query User.by_external_identifier(query) @@ -16,6 +17,8 @@ def index if skills_filter.present? @users = @users.joins(:skills).where('LOWER(skills.name) LIKE ANY (ARRAY[?])', skills_filter.map { |s| "%#{s}%" }) end + + @users = @users.where(internal: true) if only_internal.present? @users = @users.order(:first_name, :last_name) end