server/publications files, adding return parameter for easier time measure (e.g. console.time())

This commit is contained in:
Martin Filser 2023-03-11 19:32:16 +01:00
parent a37caf459e
commit 7749c0bd9a
17 changed files with 95 additions and 62 deletions

View file

@ -1,3 +1,4 @@
Meteor.publish('accountSettings', function() { Meteor.publish('accountSettings', function() {
return AccountSettings.find(); const ret = AccountSettings.find();
return ret;
}); });

View file

@ -33,8 +33,9 @@ Meteor.publish('activities', (kind, id, limit, hideSystem) => {
const selector = hideSystem const selector = hideSystem
? { $and: [{ activityType: 'addComment' }, { [`${kind}Id`]: { $in: linkedElmtId } }] } ? { $and: [{ activityType: 'addComment' }, { [`${kind}Id`]: { $in: linkedElmtId } }] }
: { [`${kind}Id`]: { $in: linkedElmtId } }; : { [`${kind}Id`]: { $in: linkedElmtId } };
return Activities.find(selector, { const ret = Activities.find(selector, {
limit, limit,
sort: { createdAt: -1 }, sort: { createdAt: -1 },
}); });
return ret;
}); });

View file

@ -1,3 +1,4 @@
Meteor.publish('announcements', function() { Meteor.publish('announcements', function() {
return Announcements.find(); const ret = Announcements.find();
return ret;
}); });

View file

@ -1,4 +1,5 @@
import Avatars from '../../models/avatars'; import Avatars from '../../models/avatars';
Meteor.publish('my-avatars', function() { Meteor.publish('my-avatars', function() {
return Avatars.find({ userId: this.userId }).cursor; const ret = Avatars.find({ userId: this.userId }).cursor;
return ret;
}); });

View file

@ -77,7 +77,8 @@ Meteor.publishRelations('boards', function() {
); );
} }
); );
return this.ready(); const ret = this.ready();
return ret;
}); });
Meteor.publish('boardsReport', function() { Meteor.publish('boardsReport', function() {
@ -132,19 +133,20 @@ Meteor.publish('boardsReport', function() {
} }
}) })
return [ const ret = [
boards, boards,
Users.find({ _id: { $in: userIds } }, { fields: Users.safeFields }), Users.find({ _id: { $in: userIds } }, { fields: Users.safeFields }),
Team.find({ _id: { $in: teamIds } }), Team.find({ _id: { $in: teamIds } }),
Org.find({ _id: { $in: orgIds } }), Org.find({ _id: { $in: orgIds } }),
] ]
return ret;
}); });
Meteor.publish('archivedBoards', function() { Meteor.publish('archivedBoards', function() {
const userId = this.userId; const userId = this.userId;
if (!Match.test(userId, String)) return []; if (!Match.test(userId, String)) return [];
return Boards.find( const ret = Boards.find(
{ {
_id: { $in: Boards.userBoardIds(userId, true)}, _id: { $in: Boards.userBoardIds(userId, true)},
archived: true, archived: true,
@ -168,6 +170,7 @@ Meteor.publish('archivedBoards', function() {
sort: { archivedAt: -1, modifiedAt: -1 }, sort: { archivedAt: -1, modifiedAt: -1 },
}, },
); );
return ret;
}); });
// If isArchived = false, this will only return board elements which are not archived. // If isArchived = false, this will only return board elements which are not archived.
@ -332,7 +335,8 @@ Meteor.publishRelations('board', function(boardId, isArchived) {
}, },
); );
return this.ready(); const ret = this.ready();
return ret;
}); });
Meteor.methods({ Meteor.methods({
@ -340,13 +344,14 @@ Meteor.methods({
check(boardId, String); check(boardId, String);
check(properties, Object); check(properties, Object);
let ret = null;
const board = ReactiveCache.getBoard(boardId); const board = ReactiveCache.getBoard(boardId);
if (board) { if (board) {
for (const key in properties) { for (const key in properties) {
board[key] = properties[key]; board[key] = properties[key];
} }
return board.copy(); ret = board.copy();
} }
return null; return ret;
}, },
}); });

View file

@ -72,7 +72,8 @@ Meteor.publishRelations('popupCardData', function(cardId) {
this.cursor(Lists.find({boardId: card.boardId})); this.cursor(Lists.find({boardId: card.boardId}));
}, },
); );
return this.ready() const ret = this.ready()
return ret;
}); });
Meteor.publish('myCards', function(sessionId) { Meteor.publish('myCards', function(sessionId) {
@ -89,7 +90,8 @@ Meteor.publish('myCards', function(sessionId) {
listId: 1, listId: 1,
}; };
return findCards(sessionId, query); const ret = findCards(sessionId, query);
return ret;
}); });
// Meteor.publish('dueCards', function(sessionId, allUsers = false) { // Meteor.publish('dueCards', function(sessionId, allUsers = false) {
@ -121,7 +123,8 @@ Meteor.publish('globalSearch', function(sessionId, params, text) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
// console.log('queryParams:', params); // console.log('queryParams:', params);
return findCards(sessionId, buildQuery(new QueryParams(params, text))); const ret = findCards(sessionId, buildQuery(new QueryParams(params, text)));
return ret;
}); });
function buildSelector(queryParams) { function buildSelector(queryParams) {
@ -642,7 +645,8 @@ Meteor.publish('brokenCards', function(sessionId) {
]; ];
// console.log('brokenCards selector:', query.selector); // console.log('brokenCards selector:', query.selector);
return findCards(sessionId, query); const ret = findCards(sessionId, query);
return ret;
}); });
Meteor.publish('nextPage', function(sessionId) { Meteor.publish('nextPage', function(sessionId) {
@ -652,7 +656,8 @@ Meteor.publish('nextPage', function(sessionId) {
const projection = session.getProjection(); const projection = session.getProjection();
projection.skip = session.lastHit; projection.skip = session.lastHit;
return findCards(sessionId, new Query(session.getSelector(), projection)); const ret = findCards(sessionId, new Query(session.getSelector(), projection));
return ret;
}); });
Meteor.publish('previousPage', function(sessionId) { Meteor.publish('previousPage', function(sessionId) {
@ -662,7 +667,8 @@ Meteor.publish('previousPage', function(sessionId) {
const projection = session.getProjection(); const projection = session.getProjection();
projection.skip = session.lastHit - session.resultsCount - projection.limit; projection.skip = session.lastHit - session.resultsCount - projection.limit;
return findCards(sessionId, new Query(session.getSelector(), projection)); const ret = findCards(sessionId, new Query(session.getSelector(), projection));
return ret;
}); });
function findCards(sessionId, query) { function findCards(sessionId, query) {

View file

@ -1,3 +1,4 @@
Meteor.publish('customFields', function() { Meteor.publish('customFields', function() {
return CustomFields.find(); const ret = CustomFields.find();
return ret;
}); });

View file

@ -4,95 +4,104 @@ import { ReactiveCache } from '/imports/reactiveCache';
// gets all activities associated with the current user // gets all activities associated with the current user
Meteor.publish('notificationActivities', () => { Meteor.publish('notificationActivities', () => {
return activities(); const ret = activities();
return ret;
}); });
// gets all attachments associated with activities associated with the current user // gets all attachments associated with activities associated with the current user
Meteor.publish('notificationAttachments', function() { Meteor.publish('notificationAttachments', function() {
return Attachments.find({ const ret = Attachments.find({
_id: { _id: {
$in: activities() $in: activities()
.map(v => v.attachmentId) .map(v => v.attachmentId)
.filter(v => !!v), .filter(v => !!v),
}.cursor, }.cursor,
}); });
return ret;
}); });
// gets all cards associated with activities associated with the current user // gets all cards associated with activities associated with the current user
Meteor.publish('notificationCards', function() { Meteor.publish('notificationCards', function() {
return Cards.find({ const ret = Cards.find({
_id: { _id: {
$in: activities() $in: activities()
.map(v => v.cardId) .map(v => v.cardId)
.filter(v => !!v), .filter(v => !!v),
}, },
}); });
return ret;
}); });
// gets all checklistItems associated with activities associated with the current user // gets all checklistItems associated with activities associated with the current user
Meteor.publish('notificationChecklistItems', function() { Meteor.publish('notificationChecklistItems', function() {
return ChecklistItems.find({ const ret = ChecklistItems.find({
_id: { _id: {
$in: activities() $in: activities()
.map(v => v.checklistItemId) .map(v => v.checklistItemId)
.filter(v => !!v), .filter(v => !!v),
}, },
}); });
return ret;
}); });
// gets all checklists associated with activities associated with the current user // gets all checklists associated with activities associated with the current user
Meteor.publish('notificationChecklists', function() { Meteor.publish('notificationChecklists', function() {
return Checklists.find({ const ret = Checklists.find({
_id: { _id: {
$in: activities() $in: activities()
.map(v => v.checklistId) .map(v => v.checklistId)
.filter(v => !!v), .filter(v => !!v),
}, },
}); });
return ret;
}); });
// gets all comments associated with activities associated with the current user // gets all comments associated with activities associated with the current user
Meteor.publish('notificationComments', function() { Meteor.publish('notificationComments', function() {
return CardComments.find({ const ret = CardComments.find({
_id: { _id: {
$in: activities() $in: activities()
.map(v => v.commentId) .map(v => v.commentId)
.filter(v => !!v), .filter(v => !!v),
}, },
}); });
return ret;
}); });
// gets all lists associated with activities associated with the current user // gets all lists associated with activities associated with the current user
Meteor.publish('notificationLists', function() { Meteor.publish('notificationLists', function() {
return Lists.find({ const ret = Lists.find({
_id: { _id: {
$in: activities() $in: activities()
.map(v => v.listId) .map(v => v.listId)
.filter(v => !!v), .filter(v => !!v),
}, },
}); });
return ret;
}); });
// gets all swimlanes associated with activities associated with the current user // gets all swimlanes associated with activities associated with the current user
Meteor.publish('notificationSwimlanes', function() { Meteor.publish('notificationSwimlanes', function() {
return Swimlanes.find({ const ret = Swimlanes.find({
_id: { _id: {
$in: activities() $in: activities()
.map(v => v.swimlaneId) .map(v => v.swimlaneId)
.filter(v => !!v), .filter(v => !!v),
}, },
}); });
return ret;
}); });
// gets all users associated with activities associated with the current user // gets all users associated with activities associated with the current user
Meteor.publish('notificationUsers', function() { Meteor.publish('notificationUsers', function() {
return Users.find({ const ret = Users.find({
_id: { _id: {
$in: activities() $in: activities()
.map(v => v.userId) .map(v => v.userId)
.filter(v => !!v), .filter(v => !!v),
}, },
}); });
return ret;
}); });
function activities() { function activities() {

View file

@ -4,13 +4,11 @@ Meteor.publish('org', function(query, limit) {
check(query, Match.OneOf(Object, null)); check(query, Match.OneOf(Object, null));
check(limit, Number); check(limit, Number);
let ret = [];
const user = ReactiveCache.getCurrentUser(); const user = ReactiveCache.getCurrentUser();
if (!user) {
return [];
}
if (user && user.isAdmin) { if (user && user.isAdmin) {
return Org.find(query, { ret = Org.find(query, {
limit, limit,
sort: { createdAt: -1 }, sort: { createdAt: -1 },
fields: { fields: {
@ -25,5 +23,5 @@ Meteor.publish('org', function(query, limit) {
}); });
} }
return []; return ret;
}); });

View file

@ -4,13 +4,11 @@ Meteor.publish('people', function(query, limit) {
check(query, Match.OneOf(Object, null)); check(query, Match.OneOf(Object, null));
check(limit, Number); check(limit, Number);
let ret = [];
const user = ReactiveCache.getCurrentUser(); const user = ReactiveCache.getCurrentUser();
if (!user) {
return [];
}
if (user && user.isAdmin) { if (user && user.isAdmin) {
return Users.find(query, { ret = Users.find(query, {
limit, limit,
sort: { createdAt: -1 }, sort: { createdAt: -1 },
fields: { fields: {
@ -29,5 +27,5 @@ Meteor.publish('people', function(query, limit) {
}); });
} }
return []; return ret;
}); });

View file

@ -5,21 +5,25 @@ import Rules from '/models/rules';
Meteor.publish('rules', ruleId => { Meteor.publish('rules', ruleId => {
check(ruleId, String); check(ruleId, String);
return Rules.find({ const ret = Rules.find({
_id: ruleId, _id: ruleId,
}); });
return ret;
}); });
Meteor.publish('allRules', () => { Meteor.publish('allRules', () => {
return Rules.find({}); const ret = Rules.find({});
return ret;
}); });
Meteor.publish('allTriggers', () => { Meteor.publish('allTriggers', () => {
return Triggers.find({}); const ret = Triggers.find({});
return ret;
}); });
Meteor.publish('allActions', () => { Meteor.publish('allActions', () => {
return Actions.find({}); const ret = Actions.find({});
return ret;
}); });
Meteor.publish('rulesReport', () => { Meteor.publish('rulesReport', () => {
@ -34,10 +38,11 @@ Meteor.publish('rulesReport', () => {
boardIds.push(rule.boardId); boardIds.push(rule.boardId);
}); });
return [ const ret = [
rules, rules,
Actions.find({ _id: { $in: actionIds } }), Actions.find({ _id: { $in: actionIds } }),
Triggers.find({ _id: { $in: triggerIds } }), Triggers.find({ _id: { $in: triggerIds } }),
Boards.find({ _id: { $in: boardIds } }, { fields: { title: 1 } }), Boards.find({ _id: { $in: boardIds } }, { fields: { title: 1 } }),
]; ];
return ret;
}); });

View file

@ -2,12 +2,13 @@ import { ReactiveCache } from '/imports/reactiveCache';
Meteor.publish('globalwebhooks', () => { Meteor.publish('globalwebhooks', () => {
const boardId = Integrations.Const.GLOBAL_WEBHOOK_ID; const boardId = Integrations.Const.GLOBAL_WEBHOOK_ID;
return Integrations.find({ const ret = Integrations.find({
boardId, boardId,
}); });
return ret;
}); });
Meteor.publish('setting', () => { Meteor.publish('setting', () => {
return Settings.find( const ret = Settings.find(
{}, {},
{ {
fields: { fields: {
@ -36,15 +37,15 @@ Meteor.publish('setting', () => {
}, },
}, },
); );
return ret;
}); });
Meteor.publish('mailServer', function() { Meteor.publish('mailServer', function() {
const user = ReactiveCache.getCurrentUser(); const user = ReactiveCache.getCurrentUser();
if (!user) {
return []; let ret = []
}
if (user && user.isAdmin) { if (user && user.isAdmin) {
return Settings.find( ret = Settings.find(
{}, {},
{ {
fields: { fields: {
@ -57,5 +58,5 @@ Meteor.publish('mailServer', function() {
}, },
); );
} }
return []; return ret;
}); });

View file

@ -8,12 +8,13 @@ Meteor.methods({
const swimlane = ReactiveCache.getSwimlane(swimlaneId); const swimlane = ReactiveCache.getSwimlane(swimlaneId);
const toBoard = ReactiveCache.getBoard(toBoardId); const toBoard = ReactiveCache.getBoard(toBoardId);
let ret = false;
if (swimlane && toBoard) { if (swimlane && toBoard) {
swimlane.copy(toBoardId); swimlane.copy(toBoardId);
return true; ret = true;
} }
return false; return ret;
}, },
moveSwimlane(swimlaneId, toBoardId) { moveSwimlane(swimlaneId, toBoardId) {
@ -23,12 +24,13 @@ Meteor.methods({
const swimlane = ReactiveCache.getSwimlane(swimlaneId); const swimlane = ReactiveCache.getSwimlane(swimlaneId);
const toBoard = ReactiveCache.getBoard(toBoardId); const toBoard = ReactiveCache.getBoard(toBoardId);
let ret = false;
if (swimlane && toBoard) { if (swimlane && toBoard) {
swimlane.move(toBoardId); swimlane.move(toBoardId);
return true; ret = true;
} }
return false; return ret;
}, },
}); });

View file

@ -1,3 +1,4 @@
Meteor.publish('tableVisibilityModeSettings', function() { Meteor.publish('tableVisibilityModeSettings', function() {
return TableVisibilityModeSettings.find(); const ret = TableVisibilityModeSettings.find();
return ret;
}); });

View file

@ -5,11 +5,10 @@ Meteor.publish('team', function(query, limit) {
check(limit, Number); check(limit, Number);
const user = ReactiveCache.getCurrentUser(); const user = ReactiveCache.getCurrentUser();
if (!user) {
return []; let ret = [];
}
if (user && user.isAdmin) { if (user && user.isAdmin) {
return Team.find(query, { ret = Team.find(query, {
limit, limit,
sort: { createdAt: -1 }, sort: { createdAt: -1 },
fields: { fields: {
@ -24,5 +23,5 @@ Meteor.publish('team', function(query, limit) {
}); });
} }
return []; return ret;
}); });

View file

@ -1,5 +1,6 @@
Meteor.publish('unsaved-edits', function() { Meteor.publish('unsaved-edits', function() {
return UnsavedEditCollection.find({ const ret = UnsavedEditCollection.find({
userId: this.userId, userId: this.userId,
}); });
return ret;
}); });

View file

@ -3,7 +3,7 @@ Meteor.publish('user-miniprofile', function (usernames) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
// console.log('usernames:', usernames); // console.log('usernames:', usernames);
return Users.find( const ret = Users.find(
{ {
$or: [ $or: [
{ username: { $in: usernames } }, { username: { $in: usernames } },
@ -17,10 +17,11 @@ Meteor.publish('user-miniprofile', function (usernames) {
}, },
}, },
); );
return ret;
}); });
Meteor.publish('user-admin', function () { Meteor.publish('user-admin', function () {
return Meteor.users.find(this.userId, { const ret = Meteor.users.find(this.userId, {
fields: { fields: {
isAdmin: 1, isAdmin: 1,
teams: 1, teams: 1,
@ -28,11 +29,12 @@ Meteor.publish('user-admin', function () {
authenticationMethod: 1, authenticationMethod: 1,
}, },
}); });
return ret;
}); });
Meteor.publish('user-authenticationMethod', function (match) { Meteor.publish('user-authenticationMethod', function (match) {
check(match, String); check(match, String);
return Users.find( const ret = Users.find(
{ $or: [{ _id: match }, { email: match }, { username: match }] }, { $or: [{ _id: match }, { email: match }, { username: match }] },
{ {
fields: { fields: {
@ -42,6 +44,7 @@ Meteor.publish('user-authenticationMethod', function (match) {
}, },
}, },
); );
return ret;
}); });
// update last connection date and last connection average time (in seconds) for a user // update last connection date and last connection average time (in seconds) for a user