summaryrefslogtreecommitdiff
path: root/app/helpers/graph_helper.rb
blob: 1022070ab6f975393b1608187bcf91ddc94a880a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module GraphHelper
  def refs(repo, commit)
    refs = commit.ref_names(repo).join(' ')

    # append note count
    notes_count = @graph.notes[commit.id]
    refs << "[#{pluralize(notes_count, 'note')}]" if notes_count > 0

    refs
  end

  def parents_zip_spaces(parents, parent_spaces)
    ids = parents.map { |p| p.id }
    ids.zip(parent_spaces)
  end

  def success_ratio(counts)
    return 100 if counts[:failed].zero?

    ratio = (counts[:success].to_f / (counts[:success] + counts[:failed])) * 100
    ratio.to_i
  end
end