<commit_before>module Aptible
  module CLI
    module ResourceFormatter
      class << self
        NO_NESTING = Object.new.freeze

        def inject_backup(node, backup, include_db: false)
          description = "#{backup.id}: #{backup.created_at}, " \
                        "#{backup.aws_region}"

          if include_db
            db = backup.database_with_deleted
            node.keyed_object('database', 'id') do |n|
              inject_deleted_database(n, db, backup.account)
            end

            description = "#{description}, " \
                          "#{db.handle} deleted at #{db.deleted_at}"
          end

          node.value('id', backup.id)
          node.value('description', description)
          node.value('created_at', backup.created_at)
          node.value('region', backup.aws_region)
          node.value('size', backup.size)

          if backup.copied_from
            node.keyed_object('copied_from', 'description') do |n|
              inject_backup(n, backup.copied_from)
            end
          end
        end

        def inject_deleted_database(node, database, account)
          node.value('id', database.id)
          node.value('handle', database.handle)
          node.value('type', database.type)
          node.value('deleted_at', database.deleted_at)
          attach_account(node, account)
        end

        def inject_account(node, account)
          node.value('id', account.id)
          node.value('handle', account.handle)
        end

        def inject_operation(node, operation)<commit_msg>Show whether or not a backup was manual in the output (#275)<commit_after>module Aptible
  module CLI
    module ResourceFormatter
      class << self
        NO_NESTING = Object.new.freeze

        def inject_backup(node, backup, include_db: false)
          description = "#{backup.id}: #{backup.created_at}, " \
                        "#{backup.aws_region}"

          if include_db
            db = backup.database_with_deleted
            node.keyed_object('database', 'id') do |n|
              inject_deleted_database(n, db, backup.account)
            end

            description = "#{description}, " \
                          "#{db.handle} deleted at #{db.deleted_at}"
          end

          node.value('id', backup.id)
          node.value('description', description)
          node.value('created_at', backup.created_at)
          node.value('region', backup.aws_region)
          node.value('size', backup.size)
          node.value('manual', backup.manual)

          if backup.copied_from
            node.keyed_object('copied_from', 'description') do |n|
              inject_backup(n, backup.copied_from)
            end
          end
        end

        def inject_deleted_database(node, database, account)
          node.value('id', database.id)
          node.value('handle', database.handle)
          node.value('type', database.type)
          node.value('deleted_at', database.deleted_at)
          attach_account(node, account)
        end

        def inject_account(node, account)
          node.value('id', account.id)
          node.value('handle', account.handle)
        end

        def inject_operation(node, operation)
{'fraction_non_alphanumeric': 0.10983555693453305, 'fraction_numerical': 0.000930809804529941, 'mean_word_length': 1.9523809523809523, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3815665', 'n_tokens_mistral': 887, 'n_tokens_neox': 875, 'n_words': 182}