浏览代码

* Add publications for admin reports
* remove broken cards from user menu
* Adjust report titles

John R. Supplee 4 年之前
父节点
当前提交
5a6f84ce34
共有 4 个文件被更改,包括 65 次插入11 次删除
  1. 0 4
      client/components/users/userHeader.jade
  2. 1 1
      i18n/en.i18n.json
  3. 60 0
      server/publications/attachments.js
  4. 4 6
      server/publications/cards.js

+ 0 - 4
client/components/users/userHeader.jade

@@ -25,10 +25,6 @@ template(name="memberMenuPopup")
         a.js-global-search(href="{{pathFor 'global-search'}}")
         a.js-global-search(href="{{pathFor 'global-search'}}")
           i.fa.fa-search
           i.fa.fa-search
           | {{_ 'globalSearch-title'}}
           | {{_ 'globalSearch-title'}}
-      li
-        a.js-broken-cards(href="{{pathFor 'broken-cards'}}")
-          i.fa.fa-chain-broken
-          | {{_ 'broken-cards'}}
       li
       li
         a(href="{{pathFor 'home'}}")
         a(href="{{pathFor 'home'}}")
           span.fa.fa-home
           span.fa.fa-home

+ 1 - 1
i18n/en.i18n.json

@@ -992,7 +992,7 @@
   "move-swimlane": "Move Swimlane",
   "move-swimlane": "Move Swimlane",
   "moveSwimlanePopup-title": "Move Swimlane",
   "moveSwimlanePopup-title": "Move Swimlane",
   "creator": "Creator",
   "creator": "Creator",
-  "filesReportTitle": "Attachments Report",
+  "filesReportTitle": "Files Report",
   "orphanedFilesReportTitle": "Orphaned Files Report",
   "orphanedFilesReportTitle": "Orphaned Files Report",
   "reports": "Reports"
   "reports": "Reports"
 }
 }

+ 60 - 0
server/publications/attachments.js

@@ -0,0 +1,60 @@
+import Attachments, { AttachmentStorage } 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(
+    {},
+    {
+      fields: {
+        _id: 1,
+        filename: 1,
+        md5: 1,
+        length: 1,
+        contentType: 1,
+        metadata: 1,
+      },
+      sort: {
+        filename: 1,
+      },
+      limit: 250,
+    },
+  );
+  const attIds = [];
+  files.forEach(file => {
+    attIds.push(file._id._str);
+  });
+
+  return [
+    files,
+    Attachments.find({ 'copies.attachments.key': { $in: attIds } }),
+  ];
+});
+
+Meteor.publish('orphanedAttachments', function() {
+  let keys = [];
+  Attachments.find({}, { fields: { copies: 1 } }).forEach(att => {
+    keys.push(new ObjectID(att.copies.attachments.key));
+  });
+  keys.sort();
+  keys = _.uniq(keys, true);
+
+  return AttachmentStorage.find(
+    { _id: { $nin: keys } },
+    {
+      fields: {
+        _id: 1,
+        filename: 1,
+        md5: 1,
+        length: 1,
+        contentType: 1,
+        metadata: 1,
+      },
+      sort: {
+        filename: 1,
+      },
+      limit: 250,
+    },
+  );
+});

+ 4 - 6
server/publications/cards.js

@@ -45,8 +45,8 @@ import {
   PREDICATE_PUBLIC,
   PREDICATE_PUBLIC,
   PREDICATE_START_AT,
   PREDICATE_START_AT,
   PREDICATE_SYSTEM,
   PREDICATE_SYSTEM,
-} from '../../config/search-const';
-import { QueryErrors, QueryParams, Query } from '../../config/query-classes';
+} from '/config/search-const';
+import { QueryErrors, QueryParams, Query } from '/config/query-classes';
 
 
 const escapeForRegex = require('escape-string-regexp');
 const escapeForRegex = require('escape-string-regexp');
 
 
@@ -598,10 +598,8 @@ function findCards(sessionId, query) {
   // console.log('selector.$and:', query.selector.$and);
   // console.log('selector.$and:', query.selector.$and);
   // eslint-disable-next-line no-console
   // eslint-disable-next-line no-console
   // console.log('projection:', projection);
   // console.log('projection:', projection);
-  let cards;
-  // if (!query.hasErrors()) {
-  cards = Cards.find(query.selector, query.projection);
-  // }
+
+  const cards = Cards.find(query.selector, query.projection);
   // eslint-disable-next-line no-console
   // eslint-disable-next-line no-console
   // console.log('count:', cards.count());
   // console.log('count:', cards.count());