mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
server/publications files, adding return parameter for easier time measure (e.g. console.time())
This commit is contained in:
parent
a37caf459e
commit
7749c0bd9a
17 changed files with 95 additions and 62 deletions
|
@ -1,3 +1,4 @@
|
|||
Meteor.publish('accountSettings', function() {
|
||||
return AccountSettings.find();
|
||||
const ret = AccountSettings.find();
|
||||
return ret;
|
||||
});
|
||||
|
|
|
@ -33,8 +33,9 @@ Meteor.publish('activities', (kind, id, limit, hideSystem) => {
|
|||
const selector = hideSystem
|
||||
? { $and: [{ activityType: 'addComment' }, { [`${kind}Id`]: { $in: linkedElmtId } }] }
|
||||
: { [`${kind}Id`]: { $in: linkedElmtId } };
|
||||
return Activities.find(selector, {
|
||||
const ret = Activities.find(selector, {
|
||||
limit,
|
||||
sort: { createdAt: -1 },
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
Meteor.publish('announcements', function() {
|
||||
return Announcements.find();
|
||||
const ret = Announcements.find();
|
||||
return ret;
|
||||
});
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import Avatars from '../../models/avatars';
|
||||
Meteor.publish('my-avatars', function() {
|
||||
return Avatars.find({ userId: this.userId }).cursor;
|
||||
const ret = Avatars.find({ userId: this.userId }).cursor;
|
||||
return ret;
|
||||
});
|
||||
|
|
|
@ -77,7 +77,8 @@ Meteor.publishRelations('boards', function() {
|
|||
);
|
||||
}
|
||||
);
|
||||
return this.ready();
|
||||
const ret = this.ready();
|
||||
return ret;
|
||||
});
|
||||
|
||||
Meteor.publish('boardsReport', function() {
|
||||
|
@ -132,19 +133,20 @@ Meteor.publish('boardsReport', function() {
|
|||
}
|
||||
})
|
||||
|
||||
return [
|
||||
const ret = [
|
||||
boards,
|
||||
Users.find({ _id: { $in: userIds } }, { fields: Users.safeFields }),
|
||||
Team.find({ _id: { $in: teamIds } }),
|
||||
Org.find({ _id: { $in: orgIds } }),
|
||||
]
|
||||
return ret;
|
||||
});
|
||||
|
||||
Meteor.publish('archivedBoards', function() {
|
||||
const userId = this.userId;
|
||||
if (!Match.test(userId, String)) return [];
|
||||
|
||||
return Boards.find(
|
||||
const ret = Boards.find(
|
||||
{
|
||||
_id: { $in: Boards.userBoardIds(userId, true)},
|
||||
archived: true,
|
||||
|
@ -168,6 +170,7 @@ Meteor.publish('archivedBoards', function() {
|
|||
sort: { archivedAt: -1, modifiedAt: -1 },
|
||||
},
|
||||
);
|
||||
return ret;
|
||||
});
|
||||
|
||||
// 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({
|
||||
|
@ -340,13 +344,14 @@ Meteor.methods({
|
|||
check(boardId, String);
|
||||
check(properties, Object);
|
||||
|
||||
let ret = null;
|
||||
const board = ReactiveCache.getBoard(boardId);
|
||||
if (board) {
|
||||
for (const key in properties) {
|
||||
board[key] = properties[key];
|
||||
}
|
||||
return board.copy();
|
||||
ret = board.copy();
|
||||
}
|
||||
return null;
|
||||
return ret;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -72,7 +72,8 @@ Meteor.publishRelations('popupCardData', function(cardId) {
|
|||
this.cursor(Lists.find({boardId: card.boardId}));
|
||||
},
|
||||
);
|
||||
return this.ready()
|
||||
const ret = this.ready()
|
||||
return ret;
|
||||
});
|
||||
|
||||
Meteor.publish('myCards', function(sessionId) {
|
||||
|
@ -89,7 +90,8 @@ Meteor.publish('myCards', function(sessionId) {
|
|||
listId: 1,
|
||||
};
|
||||
|
||||
return findCards(sessionId, query);
|
||||
const ret = findCards(sessionId, query);
|
||||
return ret;
|
||||
});
|
||||
|
||||
// Meteor.publish('dueCards', function(sessionId, allUsers = false) {
|
||||
|
@ -121,7 +123,8 @@ Meteor.publish('globalSearch', function(sessionId, params, text) {
|
|||
// eslint-disable-next-line no-console
|
||||
// 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) {
|
||||
|
@ -642,7 +645,8 @@ Meteor.publish('brokenCards', function(sessionId) {
|
|||
];
|
||||
// console.log('brokenCards selector:', query.selector);
|
||||
|
||||
return findCards(sessionId, query);
|
||||
const ret = findCards(sessionId, query);
|
||||
return ret;
|
||||
});
|
||||
|
||||
Meteor.publish('nextPage', function(sessionId) {
|
||||
|
@ -652,7 +656,8 @@ Meteor.publish('nextPage', function(sessionId) {
|
|||
const projection = session.getProjection();
|
||||
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) {
|
||||
|
@ -662,7 +667,8 @@ Meteor.publish('previousPage', function(sessionId) {
|
|||
const projection = session.getProjection();
|
||||
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) {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
Meteor.publish('customFields', function() {
|
||||
return CustomFields.find();
|
||||
const ret = CustomFields.find();
|
||||
return ret;
|
||||
});
|
||||
|
|
|
@ -4,95 +4,104 @@ import { ReactiveCache } from '/imports/reactiveCache';
|
|||
|
||||
// gets all activities associated with the current user
|
||||
Meteor.publish('notificationActivities', () => {
|
||||
return activities();
|
||||
const ret = activities();
|
||||
return ret;
|
||||
});
|
||||
|
||||
// gets all attachments associated with activities associated with the current user
|
||||
Meteor.publish('notificationAttachments', function() {
|
||||
return Attachments.find({
|
||||
const ret = Attachments.find({
|
||||
_id: {
|
||||
$in: activities()
|
||||
.map(v => v.attachmentId)
|
||||
.filter(v => !!v),
|
||||
}.cursor,
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
|
||||
// gets all cards associated with activities associated with the current user
|
||||
Meteor.publish('notificationCards', function() {
|
||||
return Cards.find({
|
||||
const ret = Cards.find({
|
||||
_id: {
|
||||
$in: activities()
|
||||
.map(v => v.cardId)
|
||||
.filter(v => !!v),
|
||||
},
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
|
||||
// gets all checklistItems associated with activities associated with the current user
|
||||
Meteor.publish('notificationChecklistItems', function() {
|
||||
return ChecklistItems.find({
|
||||
const ret = ChecklistItems.find({
|
||||
_id: {
|
||||
$in: activities()
|
||||
.map(v => v.checklistItemId)
|
||||
.filter(v => !!v),
|
||||
},
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
|
||||
// gets all checklists associated with activities associated with the current user
|
||||
Meteor.publish('notificationChecklists', function() {
|
||||
return Checklists.find({
|
||||
const ret = Checklists.find({
|
||||
_id: {
|
||||
$in: activities()
|
||||
.map(v => v.checklistId)
|
||||
.filter(v => !!v),
|
||||
},
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
|
||||
// gets all comments associated with activities associated with the current user
|
||||
Meteor.publish('notificationComments', function() {
|
||||
return CardComments.find({
|
||||
const ret = CardComments.find({
|
||||
_id: {
|
||||
$in: activities()
|
||||
.map(v => v.commentId)
|
||||
.filter(v => !!v),
|
||||
},
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
|
||||
// gets all lists associated with activities associated with the current user
|
||||
Meteor.publish('notificationLists', function() {
|
||||
return Lists.find({
|
||||
const ret = Lists.find({
|
||||
_id: {
|
||||
$in: activities()
|
||||
.map(v => v.listId)
|
||||
.filter(v => !!v),
|
||||
},
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
|
||||
// gets all swimlanes associated with activities associated with the current user
|
||||
Meteor.publish('notificationSwimlanes', function() {
|
||||
return Swimlanes.find({
|
||||
const ret = Swimlanes.find({
|
||||
_id: {
|
||||
$in: activities()
|
||||
.map(v => v.swimlaneId)
|
||||
.filter(v => !!v),
|
||||
},
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
|
||||
// gets all users associated with activities associated with the current user
|
||||
Meteor.publish('notificationUsers', function() {
|
||||
return Users.find({
|
||||
const ret = Users.find({
|
||||
_id: {
|
||||
$in: activities()
|
||||
.map(v => v.userId)
|
||||
.filter(v => !!v),
|
||||
},
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
|
||||
function activities() {
|
||||
|
|
|
@ -4,13 +4,11 @@ Meteor.publish('org', function(query, limit) {
|
|||
check(query, Match.OneOf(Object, null));
|
||||
check(limit, Number);
|
||||
|
||||
let ret = [];
|
||||
const user = ReactiveCache.getCurrentUser();
|
||||
if (!user) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (user && user.isAdmin) {
|
||||
return Org.find(query, {
|
||||
ret = Org.find(query, {
|
||||
limit,
|
||||
sort: { createdAt: -1 },
|
||||
fields: {
|
||||
|
@ -25,5 +23,5 @@ Meteor.publish('org', function(query, limit) {
|
|||
});
|
||||
}
|
||||
|
||||
return [];
|
||||
return ret;
|
||||
});
|
||||
|
|
|
@ -4,13 +4,11 @@ Meteor.publish('people', function(query, limit) {
|
|||
check(query, Match.OneOf(Object, null));
|
||||
check(limit, Number);
|
||||
|
||||
let ret = [];
|
||||
const user = ReactiveCache.getCurrentUser();
|
||||
if (!user) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (user && user.isAdmin) {
|
||||
return Users.find(query, {
|
||||
ret = Users.find(query, {
|
||||
limit,
|
||||
sort: { createdAt: -1 },
|
||||
fields: {
|
||||
|
@ -29,5 +27,5 @@ Meteor.publish('people', function(query, limit) {
|
|||
});
|
||||
}
|
||||
|
||||
return [];
|
||||
return ret;
|
||||
});
|
||||
|
|
|
@ -5,21 +5,25 @@ import Rules from '/models/rules';
|
|||
|
||||
Meteor.publish('rules', ruleId => {
|
||||
check(ruleId, String);
|
||||
return Rules.find({
|
||||
const ret = Rules.find({
|
||||
_id: ruleId,
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
|
||||
Meteor.publish('allRules', () => {
|
||||
return Rules.find({});
|
||||
const ret = Rules.find({});
|
||||
return ret;
|
||||
});
|
||||
|
||||
Meteor.publish('allTriggers', () => {
|
||||
return Triggers.find({});
|
||||
const ret = Triggers.find({});
|
||||
return ret;
|
||||
});
|
||||
|
||||
Meteor.publish('allActions', () => {
|
||||
return Actions.find({});
|
||||
const ret = Actions.find({});
|
||||
return ret;
|
||||
});
|
||||
|
||||
Meteor.publish('rulesReport', () => {
|
||||
|
@ -34,10 +38,11 @@ Meteor.publish('rulesReport', () => {
|
|||
boardIds.push(rule.boardId);
|
||||
});
|
||||
|
||||
return [
|
||||
const ret = [
|
||||
rules,
|
||||
Actions.find({ _id: { $in: actionIds } }),
|
||||
Triggers.find({ _id: { $in: triggerIds } }),
|
||||
Boards.find({ _id: { $in: boardIds } }, { fields: { title: 1 } }),
|
||||
];
|
||||
return ret;
|
||||
});
|
||||
|
|
|
@ -2,12 +2,13 @@ import { ReactiveCache } from '/imports/reactiveCache';
|
|||
|
||||
Meteor.publish('globalwebhooks', () => {
|
||||
const boardId = Integrations.Const.GLOBAL_WEBHOOK_ID;
|
||||
return Integrations.find({
|
||||
const ret = Integrations.find({
|
||||
boardId,
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
Meteor.publish('setting', () => {
|
||||
return Settings.find(
|
||||
const ret = Settings.find(
|
||||
{},
|
||||
{
|
||||
fields: {
|
||||
|
@ -36,15 +37,15 @@ Meteor.publish('setting', () => {
|
|||
},
|
||||
},
|
||||
);
|
||||
return ret;
|
||||
});
|
||||
|
||||
Meteor.publish('mailServer', function() {
|
||||
const user = ReactiveCache.getCurrentUser();
|
||||
if (!user) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let ret = []
|
||||
if (user && user.isAdmin) {
|
||||
return Settings.find(
|
||||
ret = Settings.find(
|
||||
{},
|
||||
{
|
||||
fields: {
|
||||
|
@ -57,5 +58,5 @@ Meteor.publish('mailServer', function() {
|
|||
},
|
||||
);
|
||||
}
|
||||
return [];
|
||||
return ret;
|
||||
});
|
||||
|
|
|
@ -8,12 +8,13 @@ Meteor.methods({
|
|||
const swimlane = ReactiveCache.getSwimlane(swimlaneId);
|
||||
const toBoard = ReactiveCache.getBoard(toBoardId);
|
||||
|
||||
let ret = false;
|
||||
if (swimlane && toBoard) {
|
||||
swimlane.copy(toBoardId);
|
||||
return true;
|
||||
ret = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return ret;
|
||||
},
|
||||
|
||||
moveSwimlane(swimlaneId, toBoardId) {
|
||||
|
@ -23,12 +24,13 @@ Meteor.methods({
|
|||
const swimlane = ReactiveCache.getSwimlane(swimlaneId);
|
||||
const toBoard = ReactiveCache.getBoard(toBoardId);
|
||||
|
||||
let ret = false;
|
||||
if (swimlane && toBoard) {
|
||||
swimlane.move(toBoardId);
|
||||
|
||||
return true;
|
||||
ret = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return ret;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
Meteor.publish('tableVisibilityModeSettings', function() {
|
||||
return TableVisibilityModeSettings.find();
|
||||
const ret = TableVisibilityModeSettings.find();
|
||||
return ret;
|
||||
});
|
||||
|
|
|
@ -5,11 +5,10 @@ Meteor.publish('team', function(query, limit) {
|
|||
check(limit, Number);
|
||||
|
||||
const user = ReactiveCache.getCurrentUser();
|
||||
if (!user) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let ret = [];
|
||||
if (user && user.isAdmin) {
|
||||
return Team.find(query, {
|
||||
ret = Team.find(query, {
|
||||
limit,
|
||||
sort: { createdAt: -1 },
|
||||
fields: {
|
||||
|
@ -24,5 +23,5 @@ Meteor.publish('team', function(query, limit) {
|
|||
});
|
||||
}
|
||||
|
||||
return [];
|
||||
return ret;
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
Meteor.publish('unsaved-edits', function() {
|
||||
return UnsavedEditCollection.find({
|
||||
const ret = UnsavedEditCollection.find({
|
||||
userId: this.userId,
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@ Meteor.publish('user-miniprofile', function (usernames) {
|
|||
|
||||
// eslint-disable-next-line no-console
|
||||
// console.log('usernames:', usernames);
|
||||
return Users.find(
|
||||
const ret = Users.find(
|
||||
{
|
||||
$or: [
|
||||
{ username: { $in: usernames } },
|
||||
|
@ -17,10 +17,11 @@ Meteor.publish('user-miniprofile', function (usernames) {
|
|||
},
|
||||
},
|
||||
);
|
||||
return ret;
|
||||
});
|
||||
|
||||
Meteor.publish('user-admin', function () {
|
||||
return Meteor.users.find(this.userId, {
|
||||
const ret = Meteor.users.find(this.userId, {
|
||||
fields: {
|
||||
isAdmin: 1,
|
||||
teams: 1,
|
||||
|
@ -28,11 +29,12 @@ Meteor.publish('user-admin', function () {
|
|||
authenticationMethod: 1,
|
||||
},
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
|
||||
Meteor.publish('user-authenticationMethod', function (match) {
|
||||
check(match, String);
|
||||
return Users.find(
|
||||
const ret = Users.find(
|
||||
{ $or: [{ _id: match }, { email: match }, { username: match }] },
|
||||
{
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue