<commit_before>module Api
  class PhysicalServersController < BaseController
    def show
      if params[:c_id]
        physical_server = PhysicalServer.find(params[:c_id])
        response_payload = physical_server.as_json
        response_payload['host_id'] = case physical_server.host
                                      when nil then nil
                                      else physical_server.host.id
                                      end

        render :json=> response_payload
      else
        super
      end
    end

    def server_ident(server)
      "Server instance: #{server.id} name:'#{server.name}'"
    end
  end<commit_msg>Refactor statement which show relationship in API<commit_after>module Api
  class PhysicalServersController < BaseController
    def show
      if params[:c_id]
        physical_server = PhysicalServer.find(params[:c_id])
        response_payload = physical_server.as_json
        response_payload['host_id'] = physical_server.host.try(:id)

        render :json=> response_payload
      else
        super
      end
    end

    def server_ident(server)
      "Server instance: #{server.id} name:'#{server.name}'"
    end
  end
{'fraction_non_alphanumeric': 0.07451312447078746, 'fraction_numerical': 0.0, 'mean_word_length': 2.110526315789474, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2006897', 'n_tokens_mistral': 311, 'n_tokens_neox': 307, 'n_words': 73}