BigW Consortium Gitlab

graph_helper.rb 793 Bytes
Newer Older
1
module GraphHelper
2
  def get_refs(repo, commit)
3
    refs = ""
4 5
    # Commit::ref_names already strips the refs/XXX from important refs (e.g. refs/heads/XXX)
    # so anything leftover is internally used by GitLab
6
    commit_refs = commit.ref_names(repo).reject { |name| name.starts_with?('refs/') }
7
    refs << commit_refs.join(' ')
8 9

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

    refs
14
  end
15 16 17 18 19

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

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

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