Commit e0c64fac authored by Jeff Stubler's avatar Jeff Stubler

Refactor for style issues

parent 860e24cc
......@@ -10,8 +10,7 @@ class Projects::BranchesController < Projects::ApplicationController
@branches = @repository.branches_sorted_by(@sort)
@branches = Kaminari.paginate_array(@branches).page(params[:page]).per(PER_PAGE)
@max_commits = @branches.reduce(0) do
|memo, branch|
@max_commits = @branches.reduce(0) do |memo, branch|
diverging_commit_counts = repository.diverging_commit_counts(branch)
[memo, diverging_commit_counts[:behind], diverging_commit_counts[:ahead]].max
end
......
......@@ -148,8 +148,7 @@ class Repository
end
def diverging_commit_counts(branch)
branch_cache_key = ('diverging_commit_counts_' + branch.name).to_sym
cache.fetch(branch_cache_key) do
cache.fetch(:"diverging_commit_counts_#{branch.name}") do
number_commits_behind = commits_between(branch.name, root_ref).size
number_commits_ahead = commits_between(root_ref, branch.name).size
......@@ -158,14 +157,13 @@ class Repository
end
def cache_keys
%i(size branch_names tag_names commit_count readme
contribution_guide changelog license)
%i(size branch_names tag_names commit_count
readme version contribution_guide changelog license)
end
def branch_cache_keys
branches.map do
|branch|
('diverging_commit_counts_' + branch.name).to_sym
branches.map do |branch|
:"diverging_commit_counts_#{branch.name}"
end
end
......@@ -177,7 +175,7 @@ class Repository
end
branches.each do |branch|
unless cache.exist?(('diverging_commit_counts_' + branch.name).to_sym)
unless cache.exist?(:"diverging_commit_counts_#{branch.name}")
send(:diverging_commit_counts, branch)
end
end
......@@ -188,14 +186,12 @@ class Repository
cache.expire(key)
end
branches.each do |branch|
cache.expire(('diverging_commit_counts_' + branch.name).to_sym)
end
expire_branch_cache
end
def expire_branch_cache
branches.each do |branch|
cache.expire(('diverging_commit_counts_' + branch.name).to_sym)
cache.expire(:"diverging_commit_counts_#{branch.name}")
end
end
......@@ -206,8 +202,8 @@ class Repository
end
branches.each do |branch|
cache.expire(('diverging_commit_counts_' + branch.name).to_sym)
send(:diverging_commit_counts, branch)
cache.expire(:"diverging_commit_counts_#{branch.name}")
diverging_commit_counts(branch)
end
end
......
- commit = @repository.commit(branch.target)
- bar_graph_width_factor = @max_commits > 0 ? 100.0/@max_commits : 0
- number_commits_behind = @repository.diverging_commit_counts(branch)[:behind]
- number_commits_ahead = @repository.diverging_commit_counts(branch)[:ahead]
- diverging_commit_counts = @repository.diverging_commit_counts(branch)
- number_commits_behind = diverging_commit_counts[:behind]
- number_commits_ahead = diverging_commit_counts[:ahead]
%li(class="js-branch-#{branch.name}")
%div
= link_to namespace_project_tree_path(@project.namespace, @project, branch.name) do
......@@ -33,13 +34,13 @@
= icon("trash-o")
- if branch.name != @repository.root_ref
.divergence-graph{ :title => "#{number_commits_ahead} commits ahead, #{number_commits_behind} commits behind #{@repository.root_ref}" }
.divergence-graph{ title: "#{number_commits_ahead} commits ahead, #{number_commits_behind} commits behind #{@repository.root_ref}" }
.graph-side
.bar.bar-behind{ :style => "width: #{number_commits_behind * bar_graph_width_factor}%" }
.bar.bar-behind{ style: "width: #{number_commits_behind * bar_graph_width_factor}%" }
%span.count.count-behind= number_commits_behind
.graph-separator
.graph-side
.bar.bar-ahead{ :style => "width: #{number_commits_ahead * bar_graph_width_factor}%" }
.bar.bar-ahead{ style: "width: #{number_commits_ahead * bar_graph_width_factor}%" }
%span.count.count-ahead= number_commits_ahead
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment