From 7d118a0c27ab17142d30dcd9278f8cef6bf84613 Mon Sep 17 00:00:00 2001 From: Amaia Castro Date: Fri, 10 Mar 2017 12:10:28 +0100 Subject: [PATCH] Add draft versions comments count to admin views --- app/models/legislation/draft_version.rb | 4 ++++ app/models/legislation/process.rb | 2 +- app/views/admin/legislation/draft_versions/index.html.erb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/legislation/draft_version.rb b/app/models/legislation/draft_version.rb index 297cef236..7b9e6a0aa 100644 --- a/app/models/legislation/draft_version.rb +++ b/app/models/legislation/draft_version.rb @@ -26,4 +26,8 @@ class Legislation::DraftVersion < ActiveRecord::Base def display_title status == 'draft' ? "#{title} *" : title end + + def total_comments + annotations.sum(:comments_count) + end end diff --git a/app/models/legislation/process.rb b/app/models/legislation/process.rb index a68e667e3..32468b834 100644 --- a/app/models/legislation/process.rb +++ b/app/models/legislation/process.rb @@ -64,7 +64,7 @@ class Legislation::Process < ActiveRecord::Base end def total_comments - questions.sum(:comments_count) + questions.sum(:comments_count) + draft_versions.map(&:total_comments).sum end def status diff --git a/app/views/admin/legislation/draft_versions/index.html.erb b/app/views/admin/legislation/draft_versions/index.html.erb index 6d9418c99..bfe7d33f6 100644 --- a/app/views/admin/legislation/draft_versions/index.html.erb +++ b/app/views/admin/legislation/draft_versions/index.html.erb @@ -41,7 +41,7 @@ <%= draft_version.created_at.to_date %> <%= draft_version.status %> <%= link_to "(#{t('.preview')})", legislation_process_draft_version_path(@process, draft_version) if draft_version.status == 'draft' %> - <%#= draft_version.comments %> + <%= draft_version.total_comments %> <%= draft_version.final_version %> <% end %>