gitlab-org--gitlab-foss/app/helpers/graph_helper.rb
Vladislav Kaverin fee5e17fe0 Print notes number explained.
Printing just `[<number>]` was confusing - it looks like a ghost branch or something.
Add `note` (or `notes`, depending on number of notes) to give some details of what this number means.
Refactor code to follow DRY principle.
2017-09-08 11:36:58 +04:00

27 lines
793 B
Ruby

module GraphHelper
def get_refs(repo, commit)
refs = ""
# Commit::ref_names already strips the refs/XXX from important refs (e.g. refs/heads/XXX)
# so anything leftover is internally used by GitLab
commit_refs = commit.ref_names(repo).reject { |name| name.starts_with?('refs/') }
refs << commit_refs.join(' ')
# append note count
notes_count = @graph.notes[commit.id]
refs << "[#{notes_count} #{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