Class: Neetob::CLI::MonthlyAudit::Databases::UuidPrimaryKey
- Defined in:
- lib/neetob/cli/monthly_audit/databases/uuid_primary_key.rb
Constant Summary collapse
- APP_SPECIFIC_TABLES_TO_IGNORE =
{ "neeto-auth-web" => ["global_roles"] }
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ UuidPrimaryKey
constructor
A new instance of UuidPrimaryKey.
- #run ⇒ Object
Methods included from Utils
#camel_case_to_slug, #is_upper?, #symbolize_keys
Constructor Details
#initialize ⇒ UuidPrimaryKey
Returns a new instance of UuidPrimaryKey.
13 14 15 |
# File 'lib/neetob/cli/monthly_audit/databases/uuid_primary_key.rb', line 13 def initialize super() end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/neetob/cli/monthly_audit/databases/uuid_primary_key.rb', line 17 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") } app_specific_tables_to_ignore = APP_SPECIFIC_TABLES_TO_IGNORE[repo] || [] tables_without_uuid.reject! { |table| app_specific_tables_to_ignore.include?(table) } 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(', ')}" if audit_passed == "No" issue_url = GithubIssueCreation.new.create_issue( repo:, title: "Use UUID primary keys for all tables", description: comments) audit_passed += " #{issue_url}" end 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 |