<commit_before>

class ClewApplianceInstancesSerializer < ActiveModel::Serializer

  attribute :appliances

  def appliances
    appl_set = object[:appliance_set]
    if appl_set.nil?
      []
    else
      appl_set.appliances.map { |appl| map_appliance(appl) }
    end
  end

  def map_appliance(appliance)
    {
      :id => appliance.id,
      :port_mapping_templates  => appliance.appliance_type.port_mapping_templates.map { |pmt| map_pmt(pmt) },
      :virtual_machines => appliance.deployments.map { |depl| map_vm(depl.virtual_machine) }
    }
  end

  def map_pmt(pmt)
    {
        :id => pmt.id,
        :http_mappings => pmt.http_mappings,
        :endpoints => pmt.endpoints
    }
  end

  def map_vm(vm)
    {
        :id => vm.id,
        :compute_site => vm.compute_site,
        :virtual_machine_flavor => vm.virtual_machine_flavor,
        :port_mappings => vm.port_mappings
    }
  end


end
<commit_msg>Added neccesary fields to clew_appliance_instances_serializer<commit_after>

class ClewApplianceInstancesSerializer < ActiveModel::Serializer

  attribute :appliances

  def appliances
    appl_set = object[:appliance_set]
    if appl_set.nil?
      []
    else
      appl_set.appliances.map { |appl| map_appliance(appl) }
    end
  end

  def map_appliance(appliance)
    {
      :id => appliance.id,
      :name => appliance.name,
      :description => appliance.description,
      :state => appliance.state,
      :state_explanation => appliance.state_explanation,
      :amount_billed => appliance.amount_billed,
      :prepaid_until => appliance.prepaid_until,
      :port_mapping_templates  => appliance.appliance_type.port_mapping_templates.map { |pmt| map_pmt(pmt) },
      :virtual_machines => appliance.deployments.map { |depl| map_vm(depl.virtual_machine) }
    }
  end

  def map_pmt(pmt)
    {
        :id => pmt.id,
        :http_mappings => pmt.http_mappings,
        :endpoints => pmt.endpoints
    }
  end

  def map_vm(vm)
    {
        :id => vm.id,
        :ip => vm.ip,
        :state => vm.state,
        :compute_site => vm.compute_site,
        :virtual_machine_flavor => vm.virtual_machine_flavor,
        :port_mappings => vm.port_mappings
    }
  end


end

{'fraction_non_alphanumeric': 0.10698096101541252, 'fraction_numerical': 0.0, 'mean_word_length': 2.7855917667238423, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '1786797', 'n_tokens_mistral': 803, 'n_tokens_neox': 761, 'n_words': 124}