Commit dc917552 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Cache graph log

parent 367a5d1b
...@@ -8,10 +8,18 @@ class Projects::GraphsController < Projects::ApplicationController ...@@ -8,10 +8,18 @@ class Projects::GraphsController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html format.html
format.js do format.js do
@repo = @project.repository fetch_graph
@stats = Gitlab::Git::GitStats.new(@repo.raw, @repo.root_ref)
@log = @stats.parsed_log.to_json rescue []
end end
end end
end end
private
def fetch_graph
@log = @project.repository.graph_log.to_json
@success = true
rescue => ex
@log = []
@success = false
end
end end
...@@ -61,6 +61,14 @@ class Repository ...@@ -61,6 +61,14 @@ class Repository
Rails.cache.delete(cache_key(:size)) Rails.cache.delete(cache_key(:size))
Rails.cache.delete(cache_key(:branch_names)) Rails.cache.delete(cache_key(:branch_names))
Rails.cache.delete(cache_key(:tag_names)) Rails.cache.delete(cache_key(:tag_names))
Rails.cache.delete(cache_key(:graph_log))
end
def graph_log
Rails.cache.fetch(cache_key(:graph)) do
stats = Gitlab::Git::GitStats.new(raw, root_ref)
stats.parsed_log
end
end end
def cache_key(type) def cache_key(type)
......
:plain - if @success
:plain
controller = new ContributorsStatGraph controller = new ContributorsStatGraph
controller.init(#{@log}) controller.init(#{@log})
...@@ -13,4 +14,6 @@ ...@@ -13,4 +14,6 @@
controller.change_date_header() controller.change_date_header()
controller.redraw_authors() controller.redraw_authors()
}) })
- else
:plain
$('.stat-graph').replaceWith('<div class="alert alert-error">Failed to load graph</div>')
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