From 96faeab06c82b01937070e1d0047d91b63bf7c2e Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 22 Oct 2024 00:03:42 +0300 Subject: [PATCH] make rubocop happy --- db/custom_seeds/network_prefixes.rb | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/db/custom_seeds/network_prefixes.rb b/db/custom_seeds/network_prefixes.rb index 213eb1ed6..ef6eb94ac 100644 --- a/db/custom_seeds/network_prefixes.rb +++ b/db/custom_seeds/network_prefixes.rb @@ -20,25 +20,25 @@ System::NetworkPrefix.insert_all!(network_prefixes) if network_prefixes.any? end - Dir.glob('db/network_data/**/*.yml') do |f| - System::NetworkPrefix.transaction do - puts "processing file #{f}:" # rubocop:disable Rails/Output - data = YAML.load_file(f, aliases: true) - n = data['networks'] - - System::Network.insert_all!(n) if n.any? - puts " loaded #{n.length} networks" # rubocop:disable Rails/Output - n_ids = n.map { |ni| ni['id'] }.uniq - - np = data['network_prefixes'] - System::NetworkPrefix.insert_all!(np) if np.any? - puts " loaded #{np.length} network prefixes" # rubocop:disable Rails/Output - np_ids = np.map { |npi| npi['network_id'] }.uniq - - no_prefixes = n_ids - np_ids - puts " networks without prefixes: #{no_prefixes}" if no_prefixes.any? # rubocop:disable Rails/Output - end +Dir.glob('db/network_data/**/*.yml') do |f| + System::NetworkPrefix.transaction do + puts "processing file #{f}:" # rubocop:disable Rails/Output + data = YAML.load_file(f, aliases: true) + n = data['networks'] + + System::Network.insert_all!(n) if n.any? + puts " loaded #{n.length} networks" # rubocop:disable Rails/Output + n_ids = n.map { |ni| ni['id'] }.uniq + + np = data['network_prefixes'] + System::NetworkPrefix.insert_all!(np) if np.any? + puts " loaded #{np.length} network prefixes" # rubocop:disable Rails/Output + np_ids = np.map { |npi| npi['network_id'] }.uniq + + no_prefixes = n_ids - np_ids + puts " networks without prefixes: #{no_prefixes}" if no_prefixes.any? # rubocop:disable Rails/Output end +end System::NetworkPrefix.transaction do SqlCaller::Yeti.execute "SELECT pg_catalog.setval('sys.network_types_id_seq', MAX(id), true) FROM sys.network_types"