Faster file+folder count

This commit is contained in:
Karel Pičman 2019-05-22 14:07:41 +02:00
parent 3e8594a832
commit 48ccc11ccf

View File

@ -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