2018-08-18 11:19:57 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-03-06 11:31:28 +00:00
|
|
|
module GraphHelper
|
2018-01-31 10:03:13 +00:00
|
|
|
def refs(repo, commit)
|
2018-08-18 11:19:57 +00:00
|
|
|
refs = [commit.ref_names(repo).join(' ')]
|
2013-03-26 00:51:39 +00:00
|
|
|
|
|
|
|
# append note count
|
2017-08-31 08:04:11 +00:00
|
|
|
notes_count = @graph.notes[commit.id]
|
2017-12-02 23:18:36 +00:00
|
|
|
refs << "[#{pluralize(notes_count, 'note')}]" if notes_count > 0
|
2013-03-26 00:51:39 +00:00
|
|
|
|
2018-08-18 11:19:57 +00:00
|
|
|
refs.join
|
2013-03-06 11:31:28 +00:00
|
|
|
end
|
2013-03-06 12:01:40 +00:00
|
|
|
|
|
|
|
def parents_zip_spaces(parents, parent_spaces)
|
|
|
|
ids = parents.map { |p| p.id }
|
|
|
|
ids.zip(parent_spaces)
|
|
|
|
end
|
2015-12-04 11:55:23 +00:00
|
|
|
|
2017-06-23 10:18:52 +00:00
|
|
|
def success_ratio(counts)
|
2020-08-12 06:09:53 +00:00
|
|
|
return 100 if counts[:failed] == 0
|
2015-12-04 11:55:23 +00:00
|
|
|
|
2017-06-23 10:18:52 +00:00
|
|
|
ratio = (counts[:success].to_f / (counts[:success] + counts[:failed])) * 100
|
2015-12-04 11:55:23 +00:00
|
|
|
ratio.to_i
|
|
|
|
end
|
2013-03-06 11:31:28 +00:00
|
|
|
end
|