Skip to content

Commit

Permalink
Implement review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ares committed Jan 17, 2025
1 parent 8ff2eed commit b9dc7be
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions definitions/reports/external_auth_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ def run
SELECT users.* FROM users
INNER JOIN auth_sources ON (auth_sources.id = users.auth_source_id)
WHERE auth_sources.type = 'AuthSourceExternal' AND users.last_login_on IS NOT NULL
ORDER BY users.last_login_on DESC
ORDER BY users.last_login_on DESC LIMIT 1
SQL
users = feature(:foreman_database).query(sql)
if (user = users.first)
user = feature(:foreman_database).query(sql).first
if user
data["last_login_on_through_external_auth_source_in_days"] =
(Date.today - Date.parse(user['last_login_on'])).to_i
end
Expand Down
12 changes: 6 additions & 6 deletions definitions/reports/ldap_auth_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ def run

# rubocop:disable Metrics/AbcSize
def record_flavor_usage(flavor)
query_base = query_base(flavor)
data["ldap_auth_source_#{flavor}_count"] = sql_count(query_base)
flavored_query_base = query_base(flavor)
data["ldap_auth_source_#{flavor}_count"] = sql_count(flavored_query_base)

users = feature(:foreman_database).query(user_query(flavor))
data["users_authenticated_through_ldap_auth_source_#{flavor}"] = users.count

data["last_login_on_through_ldap_auth_source_#{flavor}_in_days"] = last_login(users)

data["ldap_auth_source_#{flavor}_with_net_groups_count"] =
sql_count("#{query_base} AND use_netgroups = true")
sql_count("#{flavored_query_base} AND use_netgroups = true")

data["ldap_auth_source_#{flavor}_with_posix_groups_count"] =
sql_count("#{query_base} AND use_netgroups = false")
sql_count("#{flavored_query_base} AND use_netgroups = false")

count = sql_count("#{query_base} AND onthefly_register = false")
count = sql_count("#{flavored_query_base} AND onthefly_register = false")
data["ldap_auth_source_#{flavor}_with_account_creation_disabled_count"] = count

count = sql_count("#{query_base} AND usergroup_sync = false")
count = sql_count("#{flavored_query_base} AND usergroup_sync = false")
data["ldap_auth_source_#{flavor}_with_user_group_sync_disabled_count"] = count
end
# rubocop:enable Metrics/AbcSize
Expand Down
2 changes: 1 addition & 1 deletion lib/foreman_maintain/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MainCommand < Base
subcommand 'self-upgrade', 'Perform major version self upgrade', SelfUpgradeCommand
subcommand 'maintenance-mode', 'Control maintenance-mode for application',
MaintenanceModeCommand
subcommand 'report', 'Generate the usage reports', ReportCommand
subcommand 'report', 'Generate usage report', ReportCommand

def run(*arguments)
logger.info("Running foreman-maintain command with arguments #{arguments.inspect}")
Expand Down
4 changes: 2 additions & 2 deletions test/lib/concerns/os_facts_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ module ForemanMaintain
describe Concerns::OsFacts do
let(:system) { FakeSystem.new }

it 'should reports memory from /proc/meminfo' do
it 'should report memory from /proc/meminfo' do
File.expects(:read).with('/proc/meminfo').returns('MemTotal: 32594200 kB')

assert_equal '32594200', system.memory
end

it 'should reports CPU cores from nproc' do
it 'should report CPU cores from nproc' do
system.expects(:execute).with('nproc').returns('2')

assert_equal '2', system.cpu_cores
Expand Down

0 comments on commit b9dc7be

Please sign in to comment.