mirror of
https://github.com/wekan/wekan.git
synced 2026-02-20 23:14:07 +01:00
Update ReactiveCache call sites to use async/await for Meteor 3.0
Part 3 of ReactiveCache async migration: - Add await before all ReactiveCache.getX() calls - Make functions containing ReactiveCache calls async - Convert forEach/map/filter loops with async callbacks to for...of - Update model helpers, Meteor methods, JsonRoutes handlers - Update collection hooks (.before/.after insert/update/remove) - Update .allow() callbacks to async Files updated across models/ and server/ directories: - Model files: cards, boards, lists, swimlanes, activities, users, checklists, checklistItems, customFields, attachments, integrations, cardComments, settings files, creators, exporters, and more - Server files: publications, methods, notifications, routes, migrations
This commit is contained in:
parent
2f6e34c5f5
commit
71eb01e233
81 changed files with 2218 additions and 2148 deletions
|
|
@ -640,8 +640,8 @@ class ExporterCardPDF {
|
|||
|
||||
}
|
||||
|
||||
canExport(user) {
|
||||
const board = ReactiveCache.getBoard(this._boardId);
|
||||
async canExport(user) {
|
||||
const board = await ReactiveCache.getBoard(this._boardId);
|
||||
return board && board.isVisibleBy(user);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class ExporterExcel {
|
|||
this.userLanguage = userLanguage;
|
||||
}
|
||||
|
||||
build(res) {
|
||||
async build(res) {
|
||||
const fs = Npm.require('fs');
|
||||
const os = Npm.require('os');
|
||||
const path = Npm.require('path');
|
||||
|
|
@ -56,16 +56,16 @@ class ExporterExcel {
|
|||
};
|
||||
_.extend(
|
||||
result,
|
||||
ReactiveCache.getBoard(this._boardId, {
|
||||
await ReactiveCache.getBoard(this._boardId, {
|
||||
fields: {
|
||||
stars: 0,
|
||||
},
|
||||
}),
|
||||
);
|
||||
result.lists = ReactiveCache.getLists(byBoard, noBoardId);
|
||||
result.cards = ReactiveCache.getCards(byBoardNoLinked, noBoardId);
|
||||
result.swimlanes = ReactiveCache.getSwimlanes(byBoard, noBoardId);
|
||||
result.customFields = ReactiveCache.getCustomFields(
|
||||
result.lists = await ReactiveCache.getLists(byBoard, noBoardId);
|
||||
result.cards = await ReactiveCache.getCards(byBoardNoLinked, noBoardId);
|
||||
result.swimlanes = await ReactiveCache.getSwimlanes(byBoard, noBoardId);
|
||||
result.customFields = await ReactiveCache.getCustomFields(
|
||||
{
|
||||
boardIds: {
|
||||
$in: [this.boardId],
|
||||
|
|
@ -77,34 +77,34 @@ class ExporterExcel {
|
|||
},
|
||||
},
|
||||
);
|
||||
result.comments = ReactiveCache.getCardComments(byBoard, noBoardId);
|
||||
result.activities = ReactiveCache.getActivities(byBoard, noBoardId);
|
||||
result.rules = ReactiveCache.getRules(byBoard, noBoardId);
|
||||
result.comments = await ReactiveCache.getCardComments(byBoard, noBoardId);
|
||||
result.activities = await ReactiveCache.getActivities(byBoard, noBoardId);
|
||||
result.rules = await ReactiveCache.getRules(byBoard, noBoardId);
|
||||
result.checklists = [];
|
||||
result.checklistItems = [];
|
||||
result.subtaskItems = [];
|
||||
result.triggers = [];
|
||||
result.actions = [];
|
||||
result.cards.forEach((card) => {
|
||||
for (const card of result.cards) {
|
||||
result.checklists.push(
|
||||
...ReactiveCache.getChecklists({
|
||||
...await ReactiveCache.getChecklists({
|
||||
cardId: card._id,
|
||||
}),
|
||||
);
|
||||
result.checklistItems.push(
|
||||
...ReactiveCache.getChecklistItems({
|
||||
...await ReactiveCache.getChecklistItems({
|
||||
cardId: card._id,
|
||||
}),
|
||||
);
|
||||
result.subtaskItems.push(
|
||||
...ReactiveCache.getCards({
|
||||
...await ReactiveCache.getCards({
|
||||
parentId: card._id,
|
||||
}),
|
||||
);
|
||||
});
|
||||
result.rules.forEach((rule) => {
|
||||
}
|
||||
for (const rule of result.rules) {
|
||||
result.triggers.push(
|
||||
...ReactiveCache.getTriggers(
|
||||
...await ReactiveCache.getTriggers(
|
||||
{
|
||||
_id: rule.triggerId,
|
||||
},
|
||||
|
|
@ -112,14 +112,14 @@ class ExporterExcel {
|
|||
),
|
||||
);
|
||||
result.actions.push(
|
||||
...ReactiveCache.getActions(
|
||||
...await ReactiveCache.getActions(
|
||||
{
|
||||
_id: rule.actionId,
|
||||
},
|
||||
noBoardId,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// we also have to export some user data - as the other elements only
|
||||
// include id but we have to be careful:
|
||||
|
|
@ -169,7 +169,7 @@ class ExporterExcel {
|
|||
'profile.avatarUrl': 1,
|
||||
},
|
||||
};
|
||||
result.users = ReactiveCache.getUsers(byUserIds, userFields)
|
||||
result.users = (await ReactiveCache.getUsers(byUserIds, userFields))
|
||||
.map((user) => {
|
||||
// user avatar is stored as a relative url, we export absolute
|
||||
if ((user.profile || {}).avatarUrl) {
|
||||
|
|
@ -905,8 +905,8 @@ class ExporterExcel {
|
|||
workbook.xlsx.write(res).then(function () {});
|
||||
}
|
||||
|
||||
canExport(user) {
|
||||
const board = ReactiveCache.getBoard(this._boardId);
|
||||
async canExport(user) {
|
||||
const board = await ReactiveCache.getBoard(this._boardId);
|
||||
return board && board.isVisibleBy(user);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,12 +57,12 @@ const getBoardTitleWithMostActivities = (dateWithXdaysAgo, nbLimit) => {
|
|||
);
|
||||
};
|
||||
|
||||
const getBoards = (boardIds) => {
|
||||
const ret = ReactiveCache.getBoards({ _id: { $in: boardIds } });
|
||||
const getBoards = async (boardIds) => {
|
||||
const ret = await ReactiveCache.getBoards({ _id: { $in: boardIds } });
|
||||
return ret;
|
||||
};
|
||||
Meteor.startup(() => {
|
||||
WebApp.connectHandlers.use('/metrics', (req, res, next) => {
|
||||
WebApp.connectHandlers.use('/metrics', async (req, res, next) => {
|
||||
try {
|
||||
const ipAddress =
|
||||
req.headers['x-forwarded-for'] || req.socket.remoteAddress;
|
||||
|
|
@ -95,7 +95,7 @@ Meteor.startup(() => {
|
|||
metricsRes += '# Number of registered users\n';
|
||||
|
||||
// Get number of registered user
|
||||
resCount = ReactiveCache.getUsers({}).length; // KPI 2
|
||||
resCount = (await ReactiveCache.getUsers({})).length; // KPI 2
|
||||
metricsRes += 'wekan_registeredUsers ' + resCount + '\n';
|
||||
resCount = 0;
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ Meteor.startup(() => {
|
|||
metricsRes += '# Number of registered boards\n';
|
||||
|
||||
// Get number of registered boards
|
||||
resCount = ReactiveCache.getBoards({ archived: false, type: 'board' }).length; // KPI 3
|
||||
resCount = (await ReactiveCache.getBoards({ archived: false, type: 'board' })).length; // KPI 3
|
||||
metricsRes += 'wekan_registeredboards ' + resCount + '\n';
|
||||
resCount = 0;
|
||||
|
||||
|
|
@ -112,8 +112,8 @@ Meteor.startup(() => {
|
|||
|
||||
// Get number of registered boards by registered users
|
||||
resCount =
|
||||
ReactiveCache.getBoards({ archived: false, type: 'board' }).length /
|
||||
ReactiveCache.getUsers({}).length; // KPI 4
|
||||
(await ReactiveCache.getBoards({ archived: false, type: 'board' })).length /
|
||||
(await ReactiveCache.getUsers({})).length; // KPI 4
|
||||
metricsRes +=
|
||||
'wekan_registeredboardsBysRegisteredUsers ' + resCount + '\n';
|
||||
resCount = 0;
|
||||
|
|
@ -122,11 +122,11 @@ Meteor.startup(() => {
|
|||
metricsRes += '# Number of registered boards\n';
|
||||
|
||||
// Get board numbers with only one member
|
||||
resCount = ReactiveCache.getBoards({
|
||||
resCount = (await ReactiveCache.getBoards({
|
||||
archived: false,
|
||||
type: 'board',
|
||||
members: { $size: 1 },
|
||||
}).length; // KPI 5
|
||||
})).length; // KPI 5
|
||||
metricsRes +=
|
||||
'wekan_registeredboardsWithOnlyOneMember ' + resCount + '\n';
|
||||
resCount = 0;
|
||||
|
|
@ -144,9 +144,9 @@ Meteor.startup(() => {
|
|||
let dateWithXdaysAgo = new Date(
|
||||
new Date() - xdays * 24 * 60 * 60 * 1000,
|
||||
);
|
||||
resCount = ReactiveCache.getUsers({
|
||||
resCount = (await ReactiveCache.getUsers({
|
||||
lastConnectionDate: { $gte: dateWithXdaysAgo },
|
||||
}).length; // KPI 5
|
||||
})).length; // KPI 5
|
||||
metricsRes +=
|
||||
'wekan_usersWithLastConnectionDated5DaysAgo ' + resCount + '\n';
|
||||
resCount = 0;
|
||||
|
|
@ -157,9 +157,9 @@ Meteor.startup(() => {
|
|||
// Get number of users with last connection dated 10 days ago
|
||||
xdays = 10;
|
||||
dateWithXdaysAgo = new Date(new Date() - xdays * 24 * 60 * 60 * 1000);
|
||||
resCount = ReactiveCache.getUsers({
|
||||
resCount = (await ReactiveCache.getUsers({
|
||||
lastConnectionDate: { $gte: dateWithXdaysAgo },
|
||||
}).length; // KPI 5
|
||||
})).length; // KPI 5
|
||||
metricsRes +=
|
||||
'wekan_usersWithLastConnectionDated10DaysAgo ' + resCount + '\n';
|
||||
resCount = 0;
|
||||
|
|
@ -170,9 +170,9 @@ Meteor.startup(() => {
|
|||
// Get number of users with last connection dated 20 days ago
|
||||
xdays = 20;
|
||||
dateWithXdaysAgo = new Date(new Date() - xdays * 24 * 60 * 60 * 1000);
|
||||
resCount = ReactiveCache.getUsers({
|
||||
resCount = (await ReactiveCache.getUsers({
|
||||
lastConnectionDate: { $gte: dateWithXdaysAgo },
|
||||
}).length; // KPI 5
|
||||
})).length; // KPI 5
|
||||
metricsRes +=
|
||||
'wekan_usersWithLastConnectionDated20DaysAgo ' + resCount + '\n';
|
||||
resCount = 0;
|
||||
|
|
@ -183,9 +183,9 @@ Meteor.startup(() => {
|
|||
// Get number of users with last connection dated 20 days ago
|
||||
xdays = 30;
|
||||
dateWithXdaysAgo = new Date(new Date() - xdays * 24 * 60 * 60 * 1000);
|
||||
resCount = ReactiveCache.getUsers({
|
||||
resCount = (await ReactiveCache.getUsers({
|
||||
lastConnectionDate: { $gte: dateWithXdaysAgo },
|
||||
}).length; // KPI 5
|
||||
})).length; // KPI 5
|
||||
metricsRes +=
|
||||
'wekan_usersWithLastConnectionDated30DaysAgo ' + resCount + '\n';
|
||||
resCount = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue