show caching information for async dashboard block

This commit is contained in:
Alexander Meindl 2023-01-04 17:11:45 +01:00
parent 329914c34b
commit 3f049da0a0
15 changed files with 43 additions and 0 deletions

View File

@ -223,6 +223,9 @@ module DashboardsHelper
class: 'icon-only icon-settings',
title: l(:label_options))
end
if block_definition.key? :async
icons << tag.span('', class: 'icon-only icon-warning', title: dashboard_block_sync_info(block_definition))
end
icons << tag.span('', class: 'icon-only icon-sort-handle sort-handle', title: l(:button_move))
icons << delete_link(_remove_block_dashboard_path(@project, dashboard, block: block),
method: :post,
@ -430,6 +433,11 @@ module DashboardsHelper
private
def dashboard_block_sync_info(block_definition)
sec = block_definition[:async][:cache_expires_in].presence || DashboardContent::RENDER_ASYNC_CACHE_EXPIRES_IN
l :dashboard_block_info_async, seconds: sec
end
# Renders a single block content
def render_dashboard_block_content(block, block_definition, dashboard, **overwritten_settings)
settings = dashboard.layout_settings block

View File

@ -118,6 +118,28 @@ class DashboardContent
private
def issues_cache_expires_in
issue_count = Rails.cache.fetch project.issues.visible.count, expires_in: 1.hour do
if project
project.issues.visible.count
else
Issue.visible.count
end
end
if issue_count > 10_000
86_400 # 1 day
elsif issue_count > 1_000
3_600 # 1 hour
else
60
end
end
def issues_cache_key
Digest::SHA256.hexdigest [project&.id, User.current.id].compact.join('-')
end
# if more the one permission is specified, all permissions are required
def block_permission_allowed?(permission)
Array(permission).all? { |p| user.allowed_to?(p, project, global: true) }

View File

@ -197,3 +197,4 @@ cs:
label_all_projects: "Všechny projekty"
notice_failed_to_save_entries: "%{count} z %{total} vybrané %{name_plural} nelze uložit: %{ids}."
field_notes_count: "Počet komentářů"
dashboard_block_info_async: This block is loaded asynchronous and cached for %{seconds} seconds.

View File

@ -197,3 +197,4 @@ de:
label_all_projects: Alle Projekte
notice_failed_to_save_entries: "%{count} von %{total} ausgewählten %{name_plural} konnte(n) nicht gespeichert werden: %{ids}."
field_notes_count: Anzahl Kommentare
dashboard_block_info_async: Dieser Block wird asynchron geladen und %{seconds} Sekunden gecached.

View File

@ -197,3 +197,4 @@ en:
label_all_projects: All projects
notice_failed_to_save_entries: "%{count} of %{total} selected %{name_plural} could not be saved : %{ids}."
field_notes_count: Notes amount
dashboard_block_info_async: This block is loaded asynchronous and cached for %{seconds} seconds.

View File

@ -197,3 +197,4 @@ es:
label_all_projects: Todos los proyectos
notice_failed_to_save_entries: "%{count} de %{total} %{name_plural} seleccionados no pudieron ser salvados: %{ids}."
field_notes_count: "Número de comentarios"
dashboard_block_info_async: This block is loaded asynchronous and cached for %{seconds} seconds.

View File

@ -197,3 +197,4 @@ fr:
label_all_projects: Tous les projets
notice_failed_to_save_entries: "%{count} des %{total} %{name_plural} sélectionnés n'ont pu être sauvegardés: %{ids}."
field_notes_count: Total des commentaires
dashboard_block_info_async: This block is loaded asynchronous and cached for %{seconds} seconds.

View File

@ -197,3 +197,4 @@ it:
label_all_projects: Tutti i progetti
notice_failed_to_save_entries: "Non è stato possibile salvare %{count} dei %{total} %{name_plural} selezionati: %{ids}."
field_notes_count: Totale dei commenti
dashboard_block_info_async: This block is loaded asynchronous and cached for %{seconds} seconds.

View File

@ -197,3 +197,4 @@ ja:
label_all_projects: すべてのプロジェクト
notice_failed_to_save_entries: "%{count} of %{total} selected %{name_plural} could not be saved: %{ids}."
field_notes_count: コメント数
dashboard_block_info_async: This block is loaded asynchronous and cached for %{seconds} seconds.

View File

@ -197,3 +197,4 @@ ko:
label_all_projects: 모든 프로젝트
notice_failed_to_save_entries: "%{count} of %{total} selected %{name_plural} could not be saved: %{ids}."
field_notes_count: 메모의 수
dashboard_block_info_async: This block is loaded asynchronous and cached for %{seconds} seconds.

View File

@ -197,3 +197,4 @@ pl:
label_all_projects: Wszystkie projekty
notice_failed_to_save_entries: "%{count} z %{total} wybranych %{name_plural} nie mogły zostać zapisane: %{ids}."
field_notes_count: Liczba uwag
dashboard_block_info_async: This block is loaded asynchronous and cached for %{seconds} seconds.

View File

@ -197,3 +197,4 @@ pt-BR:
label_all_projects: Todos os Projekte
notice_failed_to_save_entries: "%{count} de %{total} %{name_plural} selecionados não puderam ser salvos: %{ids}."
field_notes_count: "Volume de comentários"
dashboard_block_info_async: This block is loaded asynchronous and cached for %{seconds} seconds.

View File

@ -197,3 +197,4 @@ ru:
label_all_projects: Все проекты
notice_failed_to_save_entries: "%{count} из %{total} выбранных %{name_plural} не удалось сохранить: %{ids}."
field_notes_count: Количество комментариев
dashboard_block_info_async: This block is loaded asynchronous and cached for %{seconds} seconds.

View File

@ -197,3 +197,4 @@
label_all_projects: 所有项目
notice_failed_to_save_entries: "%{count} of %{total} selected %{name_plural} could not be saved : %{ids}."
field_notes_count: 评论的数量
dashboard_block_info_async: This block is loaded asynchronous and cached for %{seconds} seconds.

View File

@ -197,3 +197,4 @@ zh:
label_all_projects: 所有项目
notice_failed_to_save_entries: "%{count} of %{total} selected %{name_plural} could not be saved : %{ids}."
field_notes_count: 评论的数量
dashboard_block_info_async: This block is loaded asynchronous and cached for %{seconds} seconds.