<commit_before>_ = require \underscore
W = require \../../../../lib/when

module.exports = (vg) ->
  var lines

  vg.on \pre-render (ents) ->
    map-when = vg.map.get \when
    map-when-int = if map-when then W.parse map-when, \max else W.get-int-today!
    function is-in-range edge
      edge.a_node.is-live and edge.b_node.is-live
      and W.is-in-range map-when-int, edge.when-obj.int

    # Choose the single edge to render for node-pairs having chronological edges
    node-pairs = {}
    reject-ids = []
    for e in es = ents.edges
      [id0, id1] = [e.a_node_id, e.b_node_id]
      key = if id0 < id1 then "#id0,#id1" else "#id1,#id0" # treate A-B and B-A identically
      (node-pairs[key] ?= []).push e
    for k, v of node-pairs when v.length > 1
      p = _.partition v, -> is-in-range it
      if p.0.length is 1 then reject-ids ++= _.pluck p.1, \_id else
        reject-ids ++= _.pluck v[0 til -1], \_id # all out of range, so just use the last one
    es = _.reject es, -> it._id in reject-ids

    ents.edges = _.map es, (edge) -> _.extend do
      edge
      source: _.find ents.nodes, -> it._id is edge.a_node_id
      target: _.find ents.nodes, -> it._id is edge.b_node_id

    for e in ents.edges
      e.classes = []
      e.classes.push \family if e.how in <[ daughter married son ]>
      e.classes.push \out-of-date unless is-in-range e
      e.classes.push \rename if e.how is \rename

  vg.on \render ->
    @svg.append \svg:defs .selectAll \marker
      .data <[ end ]>
      .enter!append \svg:marker
        .attr \id           String
        .attr \viewBox      '0 -5 10 10'
        .attr \refX         20
        .attr \markerWidth  15<commit_msg>refactor<commit_after>_ = require \underscore
W = require \../../../../lib/when

module.exports = (vg) ->
  var lines

  vg.on \pre-render (ents) ->
    map-when = vg.map.get \when
    map-when-int = if map-when then W.parse map-when, \max else W.get-int-today!
    function is-in-range edge
      edge.a_node.is-live and edge.b_node.is-live
      and W.is-in-range map-when-int, edge.when-obj.int

    # Choose the single edge to render for node-pairs having chronological edges
    node-pairs = {}
    reject-ids = []
    for e in es = ents.edges
      [id0, id1] = [e.a_node_id, e.b_node_id]
      key = if id0 < id1 then "#id0,#id1" else "#id1,#id0" # treate A-B and B-A identically
      (node-pairs[key] ?= []).push e
    for k, v of node-pairs when v.length > 1
      p = _.partition v, -> is-in-range it
      if p.0.length is 1 then reject-ids ++= _.pluck p.1, \_id else
        reject-ids ++= _.pluck v[0 til -1], \_id # all out of range, so just use the last one
    es = _.reject es, -> it._id in reject-ids

    nodes-by-id = _.indexBy ents.nodes, \_id
    ents.edges = _.map es, -> _.extend do
      it
      source: nodes-by-id[it.a_node_id]
      target: nodes-by-id[it.b_node_id]

    for e in ents.edges
      e.classes = []
      e.classes.push \family if e.how in <[ daughter married son ]>
      e.classes.push \out-of-date unless is-in-range e
      e.classes.push \rename if e.how is \rename

  vg.on \render ->
    @svg.append \svg:defs .selectAll \marker
      .data <[ end ]>
      .enter!append \svg:marker
        .attr \id           String
        .attr \viewBox      '0 -5 10 10'
        .attr \refX         20
        .attr \markerWidth  15
{'fraction_non_alphanumeric': 0.1392782582761706, 'fraction_numerical': 0.014315538323889055, 'mean_word_length': 1.9267015706806283, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, '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': '2991116', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1212, 'n_words': 366}