Move every Users.find(idOrFirstObjectSelector, options) to the ReactiveCache (directory server/)

This commit is contained in:
Martin Filser 2023-03-12 11:59:23 +01:00
parent 46840c9373
commit 6646b8638e
5 changed files with 23 additions and 15 deletions

View file

@ -141,7 +141,7 @@ Meteor.publish('boardsReport', function() {
const ret = [ const ret = [
boards, boards,
Users.find({ _id: { $in: userIds } }, { fields: Users.safeFields }), ReactiveCache.getUsers({ _id: { $in: userIds } }, { fields: Users.safeFields }, true),
Team.find({ _id: { $in: teamIds } }), Team.find({ _id: { $in: teamIds } }),
Org.find({ _id: { $in: orgIds } }), Org.find({ _id: { $in: orgIds } }),
] ]
@ -326,7 +326,7 @@ Meteor.publishRelations('board', function(boardId, isArchived) {
// and sending it triggers a subtle bug: // and sending it triggers a subtle bug:
// https://github.com/wefork/wekan/issues/15 // https://github.com/wefork/wekan/issues/15
this.cursor( this.cursor(
Users.find( ReactiveCache.getUsers(
{ {
_id: { $in: _.without(memberIds, thisUserId) }, _id: { $in: _.without(memberIds, thisUserId) },
}, },
@ -338,6 +338,7 @@ Meteor.publishRelations('board', function(boardId, isArchived) {
'profile.initials': 1, 'profile.initials': 1,
}, },
}, },
true,
), ),
); );

View file

@ -790,7 +790,7 @@ function findCards(sessionId, query) {
), ),
ReactiveCache.getLists({ _id: { $in: lists } }, { fields }, true), ReactiveCache.getLists({ _id: { $in: lists } }, { fields }, true),
CustomFields.find({ _id: { $in: customFieldIds } }), CustomFields.find({ _id: { $in: customFieldIds } }),
Users.find({ _id: { $in: users } }, { fields: Users.safeFields }), ReactiveCache.getUsers({ _id: { $in: users } }, { fields: Users.safeFields }, true),
Checklists.find({ cardId: { $in: cards.map(c => c._id) } }), Checklists.find({ cardId: { $in: cards.map(c => c._id) } }),
ChecklistItems.find({ cardId: { $in: cards.map(c => c._id) } }), ChecklistItems.find({ cardId: { $in: cards.map(c => c._id) } }),
Attachments.find({ 'meta.cardId': { $in: cards.map(c => c._id) } }).cursor, Attachments.find({ 'meta.cardId': { $in: cards.map(c => c._id) } }).cursor,

View file

@ -106,13 +106,17 @@ Meteor.publish('notificationSwimlanes', function() {
// 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() {
const ret = Users.find({ const ret = ReactiveCache.getUsers(
{
_id: { _id: {
$in: activities() $in: activities()
.map(v => v.userId) .map(v => v.userId)
.filter(v => !!v), .filter(v => !!v),
}, },
}); },
{},
true,
);
return ret; return ret;
}); });

View file

@ -8,7 +8,7 @@ Meteor.publish('people', function(query, limit) {
const user = ReactiveCache.getCurrentUser(); const user = ReactiveCache.getCurrentUser();
if (user && user.isAdmin) { if (user && user.isAdmin) {
ret = Users.find(query, { ret = ReactiveCache.getUsers(query, {
limit, limit,
sort: { createdAt: -1 }, sort: { createdAt: -1 },
fields: { fields: {
@ -24,7 +24,8 @@ Meteor.publish('people', function(query, limit) {
orgs: 1, orgs: 1,
teams: 1, teams: 1,
}, },
}); },
true);
} }
return ret; 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);
const ret = Users.find( const ret = ReactiveCache.getUsers(
{ {
$or: [ $or: [
{ username: { $in: usernames } }, { username: { $in: usernames } },
@ -16,6 +16,7 @@ Meteor.publish('user-miniprofile', function (usernames) {
importUsernames: 1, importUsernames: 1,
}, },
}, },
true,
); );
return ret; return ret;
}); });
@ -34,7 +35,7 @@ Meteor.publish('user-admin', function () {
Meteor.publish('user-authenticationMethod', function (match) { Meteor.publish('user-authenticationMethod', function (match) {
check(match, String); check(match, String);
const ret = Users.find( const ret = ReactiveCache.getUsers(
{ $or: [{ _id: match }, { email: match }, { username: match }] }, { $or: [{ _id: match }, { email: match }, { username: match }] },
{ {
fields: { fields: {
@ -43,6 +44,7 @@ Meteor.publish('user-authenticationMethod', function (match) {
orgs: 1, orgs: 1,
}, },
}, },
true,
); );
return ret; return ret;
}); });
@ -100,9 +102,9 @@ I20221023-09:15:09.602(3)? at packages/ddp-server/livedata_server.js:1496:18
// console.log('connection.Id on close...', connection.id); // console.log('connection.Id on close...', connection.id);
// // Get all user that were connected to this socket // // Get all user that were connected to this socket
// // And update last connection date and last connection average time (in seconds) for each user // // And update last connection date and last connection average time (in seconds) for each user
// let lstOfUserThatWasConnectedToThisSocket = Users.find({ // let lstOfUserThatWasConnectedToThisSocket = ReactiveCache.getUsers({
// lastconnectedSocketId: connection.id, // lastconnectedSocketId: connection.id,
// }).fetch(); // }, {}, true).fetch();
// if ( // if (
// lstOfUserThatWasConnectedToThisSocket !== undefined && // lstOfUserThatWasConnectedToThisSocket !== undefined &&
// lstOfUserThatWasConnectedToThisSocket.length > 0 // lstOfUserThatWasConnectedToThisSocket.length > 0