Skip to content
Snippets Groups Projects
Commit c3056d5d authored by Robert May's avatar Robert May
Browse files

Don't try this at home, kids

parent e5df1467
No related merge requests found
# frozen_string_literal: true
module CachingHelper
DEFAULT_EXPIRY = 1.day
def kit_cache_chunky(expires_in: DEFAULT_EXPIRY)
@key_blocks ||= {}
blocks = @key_blocks[template_root_key] = {}
big_ol_strang = capture do
yield
end
chunks = Rails.cache.fetch_multi(*blocks.keys, expires_in: expires_in) do |missing_key|
puts "Cache miss: #{missing_key}"
capture do
blocks[missing_key].call
end
end
chunks.each do |key, chunk|
puts "Rendering chunk: #{key}"
big_ol_strang.gsub!(key, (chunk || ""))
end
big_ol_strang.html_safe
end
def cache_chunk(*keys, &block)
key = keys.map! { |k| k.try(:cache_key) || k.to_s }.unshift(template_root_key).join(":")
@key_blocks[template_root_key][key] = block
return key
end
private
def template_root_key
digest_path_from_template(@current_template)
end
end
......@@ -9,23 +9,29 @@
= content_for :invite_members_sidebar do
= render partial: 'projects/invite_members_link'
= render partial: 'flash_messages', locals: { project: @project }
= kit_cache_chunky do
= render partial: 'flash_messages', locals: { project: @project }
= render "projects/last_push"
= render "projects/last_push"
= render "home_panel"
= render "home_panel"
- if can?(current_user, :download_code, @project) && @project.repository_languages.present?
= repository_languages_bar(@project.repository_languages)
- if can?(current_user, :download_code, @project) && @project.repository_languages.present?
= cache_chunk(@project, :language_bar, expires_in: 1.hour) do
= repository_languages_bar(@project.repository_languages)
= render "archived_notice", project: @project
= render_if_exists "projects/marked_for_deletion_notice", project: @project
= render_if_exists "projects/ancestor_group_marked_for_deletion_notice", project: @project
= cache_chunk(@project, :archive_partials) do
= render "archived_notice", project: @project
= render_if_exists "projects/marked_for_deletion_notice", project: @project
= render_if_exists "projects/ancestor_group_marked_for_deletion_notice", project: @project
- view_path = @project.default_view
- show_devops_callout = show_auto_devops_callout?(@project)
- if show_auto_devops_callout?(@project)
= render 'shared/auto_devops_callout'
= cache_chunk(@project, :auto_devops, show_devops_callout) do
- if show_auto_devops_callout?(@project)
= render 'shared/auto_devops_callout'
%div{ class: project_child_container_class(view_path) }
= render view_path, is_project_overview: true
- view_path = @project.default_view
%div{ class: project_child_container_class(view_path) }
= render view_path, is_project_overview: true
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