From 48ccc11ccff6c84c7057145286f7d6f218c328d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Wed, 22 May 2019 14:07:41 +0200 Subject: [PATCH] Faster file+folder count --- lib/redmine_dmsf/patches/project_patch.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/redmine_dmsf/patches/project_patch.rb b/lib/redmine_dmsf/patches/project_patch.rb index 236bf499..b9caf4e6 100644 --- a/lib/redmine_dmsf/patches/project_patch.rb +++ b/lib/redmine_dmsf/patches/project_patch.rb @@ -19,6 +19,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# module RedmineDmsf module Patches @@ -76,10 +77,10 @@ module RedmineDmsf end def dmsf_count - file_count = DmsfFiles.where(project_id: id).all.size + - DmsfLinks.where(project_id: id, target_type: %(DmsfFile DmsfUrl)).all.size - folder_count = DmsfFolders.where(project_id: id).all.size + - DmsfLinks.where(project_id: id, target_type: 'DmsfFolder').all.size + file_count = DmsfFile.where(project_id: id).all.size + + DmsfLink.where(project_id: id, target_type: %(DmsfFile DmsfUrl)).all.size + folder_count = DmsfFolder.where(project_id: id).all.size + + DmsfLink.where(project_id: id, target_type: 'DmsfFolder').all.size { :files => file_count, :folders => folder_count } end