From efcecd0a2727dd61fca04ce0fc098517eb119bc8 Mon Sep 17 00:00:00 2001 From: aaronskiba Date: Wed, 5 Jun 2024 16:18:52 -0600 Subject: [PATCH] Refactor @unpublished_count Since `@published_count` is already computed, the if/else handling of `published` prior to this commit was redundant --- .../org_admin/templates_controller.rb | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/app/controllers/org_admin/templates_controller.rb b/app/controllers/org_admin/templates_controller.rb index 2170d31ec..1b128ba8e 100644 --- a/app/controllers/org_admin/templates_controller.rb +++ b/app/controllers/org_admin/templates_controller.rb @@ -25,11 +25,7 @@ def index @query_params = { sort_field: 'templates.title', sort_direction: 'asc' } @all_count = templates.size @published_count = published.present? ? published : 0 - @unpublished_count = if published.present? - (@all_count - published) - else - @all_count - end + @unpublished_count = @all_count - @published_count render :index end # rubocop:enable Metrics/AbcSize @@ -55,11 +51,7 @@ def organisational @query_params = { sort_field: 'templates.title', sort_direction: 'asc' } @all_count = templates.size @published_count = published.present? ? published : 0 - @unpublished_count = if published.present? - @all_count - published - else - @all_count - end + @unpublished_count = @all_count - @published_count render :index end # rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity @@ -90,11 +82,7 @@ def customisable @query_params = { sort_field: 'templates.title', sort_direction: 'asc' } @all_count = funder_templates.size @published_count = published.present? ? published : 0 - @unpublished_count = if published.present? - (customizations_count - published) - else - customizations_count - end + @unpublished_count = customizations_count - @published_count @not_customized_count = @all_count - customizations_count render :index