Sha256: 2a52110b4db7469471bb269e027c181bd830d99f5a96a97469260155c92f8411

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

# frozen_string_literal: true

module Neetob
  class CLI
    module MonthlyAudit
      module Databases
        class UuidPrimaryKey < CLI::Base
          def initialize
            super()
          end

          def run
            repo_data = [[
              "Repository",
              "All tables have UUID primary keys",
              "Comments",
              "Audit Passed"
              ]
            ]
            last_comment = nil
            NeetoCompliance::NeetoRepos.products.keys.each do |repo|
              ui.info "Checking #{repo}...", print_to_audit_log: false
              code_audit_result = Neetob::CLI::Code::Audit.new([repo]).run[0]
              if code_audit_result[:error]
                repo_data << [repo, nil, code_audit_result[:error], "No"]
                next
              end
              tables_without_uuid = code_audit_result[:tables_without_uuid]
              tables_without_uuid.reject! { |table|
                table == "data_migrations" ||
                table == "server_side_sessions" ||
                table.include?("solid_queue") ||
                table.include?("active_storage")
              }
              all_tables_have_uuid_primary_keys = tables_without_uuid.empty? ? "Yes" : "No"
              audit_passed = all_tables_have_uuid_primary_keys == "Yes" ? "Yes" : "No"
              comments = tables_without_uuid.empty? ? nil : "Tables without UUID primary keys: #{tables_without_uuid.join(', ')}"
              same_as_last_comment = audit_passed == "No" && comments == last_comment
              last_comment = comments
              if same_as_last_comment
                comments = "''"
              end
              repo_data << [repo, all_tables_have_uuid_primary_keys, comments, audit_passed]
            end
            ui.print_table(repo_data)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
neetob-0.5.29 lib/neetob/cli/monthly_audit/databases/uuid_primary_key.rb