From dace63d4dcfbf995338332c8fb09314d0bd581e7 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Thu, 7 Apr 2022 10:25:56 +0200 Subject: [PATCH] Files Report works now with Meteor-Files (needed migration to new code) --- client/components/settings/adminReports.jade | 12 +++----- client/components/settings/adminReports.js | 10 ++----- server/publications/attachments.js | 29 ++++++-------------- 3 files changed, 15 insertions(+), 36 deletions(-) diff --git a/client/components/settings/adminReports.jade b/client/components/settings/adminReports.jade index 7a1b8cb96..fded9505a 100644 --- a/client/components/settings/adminReports.jade +++ b/client/components/settings/adminReports.jade @@ -88,18 +88,14 @@ template(name="filesReport") th Filename th.right Size (kB) th MIME Type - th.center Usage - th MD5 Sum th ID each att in results tr - td {{ att.filename }} - td.right {{fileSize att.length }} - td {{ att.contentType }} - td.center {{usageCount att._id.toHexString }} - td {{ att.md5 }} - td {{ att._id.toHexString }} + td {{ att.name }} + td.right {{fileSize att.size }} + td {{ att.type }} + td {{ att._id }} else div {{_ 'no-results' }} diff --git a/client/components/settings/adminReports.js b/client/components/settings/adminReports.js index 6dcbb0fc4..ebeca8dae 100644 --- a/client/components/settings/adminReports.js +++ b/client/components/settings/adminReports.js @@ -1,4 +1,4 @@ -import { AttachmentStorage } from '/models/attachments'; +import Attachments from '/models/attachments'; import { CardSearchPagedComponent } from '/client/lib/cardSearch'; import SessionData from '/models/usersessiondata'; import { QueryParams } from '/config/query-classes'; @@ -103,8 +103,6 @@ class AdminReport extends BlazeComponent { results() { // eslint-disable-next-line no-console - // console.log('attachments:', AttachmentStorage.find()); - // console.log('attachments.count:', AttachmentStorage.find().count()); return this.collection.find(); } @@ -124,10 +122,6 @@ class AdminReport extends BlazeComponent { return Math.round(size / 1024); } - usageCount(key) { - return Attachments.find({ 'copies.attachments.key': key }).count(); - } - abbreviate(text) { if (text.length > 30) { return `${text.substr(0, 29)}...`; @@ -137,7 +131,7 @@ class AdminReport extends BlazeComponent { } (class extends AdminReport { - collection = AttachmentStorage; + collection = Attachments; }.register('filesReport')); (class extends AdminReport { diff --git a/server/publications/attachments.js b/server/publications/attachments.js index 18566f7da..33d4d53e2 100644 --- a/server/publications/attachments.js +++ b/server/publications/attachments.js @@ -1,35 +1,24 @@ -import Attachments, { AttachmentStorage } from '/models/attachments'; +import Attachments from '/models/attachments'; import { ObjectID } from 'bson'; Meteor.publish('attachmentsList', function() { - // eslint-disable-next-line no-console - // console.log('attachments:', AttachmentStorage.find()); - const files = AttachmentStorage.find( + const ret = Attachments.find( {}, { fields: { _id: 1, - filename: 1, - md5: 1, - length: 1, - contentType: 1, - metadata: 1, + name: 1, + size: 1, + type: 1, + meta: 1, }, sort: { - filename: 1, + name: 1, }, limit: 250, }, - ); - const attIds = []; - files.forEach(file => { - attIds.push(file._id._str); - }); - - return [ - files, - Attachments.find({ 'copies.attachments.key': { $in: attIds } }), - ]; + ).cursor; + return ret; }); Meteor.publish('orphanedAttachments', function() {