Commit dc917552 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Cache graph log

parent 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%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment