提交 dc917552 编写于 作者: D Dmitriy Zaporozhets

Cache graph log

上级 367a5d1b
......@@ -8,10 +8,18 @@ class Projects::GraphsController < Projects::ApplicationController
respond_to do |format|
format.html
format.js do
@repo = @project.repository
@stats = Gitlab::Git::GitStats.new(@repo.raw, @repo.root_ref)
@log = @stats.parsed_log.to_json rescue []
fetch_graph
end
end
end
private
def fetch_graph
@log = @project.repository.graph_log.to_json
@success = true
rescue => ex
@log = []
@success = false
end
end
......@@ -61,6 +61,14 @@ class Repository
Rails.cache.delete(cache_key(:size))
Rails.cache.delete(cache_key(:branch_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
def cache_key(type)
......
:plain
controller = new ContributorsStatGraph
controller.init(#{@log})
- if @success
:plain
controller = new ContributorsStatGraph
controller.init(#{@log})
$("select").change( function () {
var field = $(this).val()
controller.set_current_field(field)
controller.redraw_master()
controller.redraw_authors()
})
$("#brush_change").change( function () {
controller.change_date_header()
controller.redraw_authors()
})
$("select").change( function () {
var field = $(this).val()
controller.set_current_field(field)
controller.redraw_master()
controller.redraw_authors()
})
$("#brush_change").change( function () {
controller.change_date_header()
controller.redraw_authors()
})
- else
:plain
$('.stat-graph').replaceWith('<div class="alert alert-error">Failed to load graph</div>')
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册