diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb index a3788e6d..f0605acc 100644 --- a/app/models/dmsf_folder.rb +++ b/app/models/dmsf_folder.rb @@ -230,25 +230,6 @@ class DmsfFolder < ActiveRecord::Base options end - def deep_file_count - file_count = dmsf_files.visible.all.size - dmsf_folders.visible.each { |subfolder| file_count += subfolder.deep_file_count } - file_count + file_links.visible.all.size + url_links.visible.all.size - end - - def deep_folder_count - folder_count = dmsf_folders.visible.all.size - dmsf_folders.visible.each { |subfolder| folder_count += subfolder.deep_folder_count } - folder_count + folder_links.visible.all.size - end - - def deep_size - size = 0 - dmsf_files.visible.each {|file| size += file.size} - dmsf_folders.visible.each {|subfolder| size += subfolder.deep_size} - size - end - # Returns an array of projects that current user can copy folder to def self.allowed_target_projects_on_copy projects = [] diff --git a/lib/redmine_dmsf/patches/project_patch.rb b/lib/redmine_dmsf/patches/project_patch.rb index b2a0f77c..236bf499 100644 --- a/lib/redmine_dmsf/patches/project_patch.rb +++ b/lib/redmine_dmsf/patches/project_patch.rb @@ -76,12 +76,10 @@ module RedmineDmsf end def dmsf_count - file_count = self.dmsf_files.visible.count + self.file_links.visible.count - folder_count = self.dmsf_folders.visible.count + self.folder_links.visible.count - self.dmsf_folders.visible.each do |f| - file_count += f.deep_file_count - folder_count += f.deep_folder_count - end + 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 { :files => file_count, :folders => folder_count } end