See suggested refactoring in https://github.com/RamenDR/ramen/pull/2739#discussion_r4036713275
See suggested refactoring in #2739 (comment)