Skip to content

Commit

Permalink
Refactor @unpublished_count
Browse files Browse the repository at this point in the history
Since `@published_count` is already computed, the if/else handling of `published` prior to this commit was redundant
  • Loading branch information
aaronskiba committed Jun 11, 2024
1 parent 70f08fa commit efcecd0
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions app/controllers/org_admin/templates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit efcecd0

Please sign in to comment.