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