<commit_before>module TopologiesHelper
  def topology_field_value(topology)
    if topology.new_record? && topology.graph.blank?
      TopologyTemplate::DEFAULT_GRAPH
    elsif topology.graph.is_a?(String)
      topology.graph
    else
      JSON.dump(topology.graph.to_hash)
    end
  end

  def edge_nodes_for(topology)
    Topologies::EdgeNodesFinder.new(topology.graph).find_edge_nodes.map do |node|
      node.key
    end
  end<commit_msg>Convert topology graph as string to json<commit_after>module TopologiesHelper
  def topology_field_value(topology)
    if topology.new_record? && topology.graph.blank?
      TopologyTemplate::DEFAULT_GRAPH
    elsif topology.graph.is_a?(String)
      topology.graph.to_json
    else
      JSON.dump(topology.graph.to_hash)
    end
  end

  def edge_nodes_for(topology)
    Topologies::EdgeNodesFinder.new(topology.graph).find_edge_nodes.map do |node|
      node.key
    end
  end
{'fraction_non_alphanumeric': 0.08342361863488625, 'fraction_numerical': 0.0, 'mean_word_length': 3.7142857142857144, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2468160', 'n_tokens_mistral': 312, 'n_tokens_neox': 302, 'n_words': 51}