Skip to content

Add opened/closed epic issue weights and counts

Jan Provaznik requested to merge jp-cached-issue-weight into master

What does this MR do and why?

Because counting issue weights for all epics in a board list is too expensive (&7780 (comment 980261253)), we will have to cache this value(s). Although for showing just total issue weight we could cache only open+closed weight (and not distinguish between finished/unfinished), it's little bit more flexible to store both values separately (in case we would want to show e.g. progress of total weight - similar we show per each epic).

if we cache epic issue weights, then it's a minimum overhead to cache also issue counts for epic - and if we cache both weight and count, then we will be able to use this caching also on other places where epic's descendant weight/count is used - see #356682 (comment 985381275) for details.

Related to #356682 (closed)

Update: also related to &7780 (comment 993065522) - the plan is to cache total issue weight/count (including sub-epics) - I renamed columsn accordingly

Screenshots or screen recordings

DB output:

$ rake db:migrate
main: == 20220610074326 AddEpicIssueWeight: migrating ===============================
main: -- add_column(:epics, :total_opened_issue_weight, :integer, {:default=>0, :null=>false})
main:    -> 0.0018s
main: -- add_column(:epics, :total_closed_issue_weight, :integer, {:default=>0, :null=>false})
main:    -> 0.0007s
main: -- add_column(:epics, :total_opened_issue_count, :integer, {:default=>0, :null=>false})
main:    -> 0.0007s
main: -- add_column(:epics, :total_closed_issue_count, :integer, {:default=>0, :null=>false})
main:    -> 0.0007s
main: == 20220610074326 AddEpicIssueWeight: migrated (0.0044s) ======================

ci: == 20220610074326 AddEpicIssueWeight: migrating ===============================
ci: -- add_column(:epics, :total_opened_issue_weight, :integer, {:default=>0, :null=>false})
ci:    -> 0.0015s
ci: -- add_column(:epics, :total_closed_issue_weight, :integer, {:default=>0, :null=>false})
ci:    -> 0.0007s
ci: -- add_column(:epics, :total_opened_issue_count, :integer, {:default=>0, :null=>false})
ci:    -> 0.0008s
ci: -- add_column(:epics, :total_closed_issue_count, :integer, {:default=>0, :null=>false})
ci:    -> 0.0008s
ci: == 20220610074326 AddEpicIssueWeight: migrated (0.0040s) ======================


$ rake db:rollback:ci db:rollback:main
ci: == 20220610074326 AddEpicIssueWeight: reverting ===============================
ci: -- remove_column(:epics, :total_closed_issue_count, :integer, {:default=>0, :null=>false})
ci:    -> 0.0016s
ci: -- remove_column(:epics, :total_opened_issue_count, :integer, {:default=>0, :null=>false})
ci:    -> 0.0004s
ci: -- remove_column(:epics, :total_closed_issue_weight, :integer, {:default=>0, :null=>false})
ci:    -> 0.0005s
ci: -- remove_column(:epics, :total_opened_issue_weight, :integer, {:default=>0, :null=>false})
ci:    -> 0.0004s
ci: == 20220610074326 AddEpicIssueWeight: reverted (0.0052s) ======================

main: == 20220610074326 AddEpicIssueWeight: reverting ===============================
main: -- remove_column(:epics, :total_closed_issue_count, :integer, {:default=>0, :null=>false})
main:    -> 0.0012s
main: -- remove_column(:epics, :total_opened_issue_count, :integer, {:default=>0, :null=>false})
main:    -> 0.0005s
main: -- remove_column(:epics, :total_closed_issue_weight, :integer, {:default=>0, :null=>false})
main:    -> 0.0005s
main: -- remove_column(:epics, :total_opened_issue_weight, :integer, {:default=>0, :null=>false})
main:    -> 0.0005s
main: == 20220610074326 AddEpicIssueWeight: reverted (0.0029s) ======================

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jan Provaznik

Merge request reports