2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
module GraphHelper
|
2018-03-17 18:26:18 +05:30
|
|
|
def refs(repo, commit)
|
2018-12-05 23:21:45 +05:30
|
|
|
refs = [commit.ref_names(repo).join(' ')]
|
2014-09-02 18:07:02 +05:30
|
|
|
|
|
|
|
# append note count
|
2018-03-17 18:26:18 +05:30
|
|
|
notes_count = @graph.notes[commit.id]
|
|
|
|
refs << "[#{pluralize(notes_count, 'note')}]" if notes_count > 0
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
refs.join
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def parents_zip_spaces(parents, parent_spaces)
|
|
|
|
ids = parents.map { |p| p.id }
|
|
|
|
ids.zip(parent_spaces)
|
|
|
|
end
|
2015-12-23 02:04:40 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
def success_ratio(counts)
|
2020-10-24 23:57:45 +05:30
|
|
|
return 100 if counts[:failed] == 0
|
2015-12-23 02:04:40 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
ratio = (counts[:success].to_f / (counts[:success] + counts[:failed])) * 100
|
2015-12-23 02:04:40 +05:30
|
|
|
ratio.to_i
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|