mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
ReactiveMiniMongoIndex for Server-Side
- fixes: #5069 (move card rule on checklist complete doesn't work)
This commit is contained in:
parent
67b99a88fc
commit
a9932823c4
1 changed files with 120 additions and 6 deletions
|
|
@ -1321,9 +1321,63 @@ ReactiveCache = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Server isn't reactive, so search for the data always.
|
||||||
|
ReactiveMiniMongoIndexServer = {
|
||||||
|
getSubTasksWithParentId(parentId, addSelect = {}, options = {}) {
|
||||||
|
let ret = []
|
||||||
|
if (parentId) {
|
||||||
|
ret = ReactiveCache.getCards(
|
||||||
|
{ parentId,
|
||||||
|
...addSelect,
|
||||||
|
}, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getChecklistsWithCardId(cardId, addSelect = {}, options = {}) {
|
||||||
|
let ret = []
|
||||||
|
if (cardId) {
|
||||||
|
ret = ReactiveCache.getChecklists(
|
||||||
|
{ cardId,
|
||||||
|
...addSelect,
|
||||||
|
}, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getChecklistItemsWithChecklistId(checklistId, addSelect = {}, options = {}) {
|
||||||
|
let ret = []
|
||||||
|
if (checklistId) {
|
||||||
|
ret = ReactiveCache.getChecklistItems(
|
||||||
|
{ checklistId,
|
||||||
|
...addSelect,
|
||||||
|
}, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getCardCommentsWithCardId(cardId, addSelect = {}, options = {}) {
|
||||||
|
let ret = []
|
||||||
|
if (cardId) {
|
||||||
|
ret = ReactiveCache.getCardComments(
|
||||||
|
{ cardId,
|
||||||
|
...addSelect,
|
||||||
|
}, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getActivityWithId(activityId, addSelect = {}, options = {}) {
|
||||||
|
let ret = []
|
||||||
|
if (activityId) {
|
||||||
|
ret = ReactiveCache.getActivities(
|
||||||
|
{ _id: activityId,
|
||||||
|
...addSelect,
|
||||||
|
}, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Client side little MiniMongo DB "Index"
|
// Client side little MiniMongo DB "Index"
|
||||||
ReactiveMiniMongoIndex = {
|
ReactiveMiniMongoIndexClient = {
|
||||||
getSubTasksWithParentId(parentId, addSelect = {}, options) {
|
getSubTasksWithParentId(parentId, addSelect = {}, options = {}) {
|
||||||
let ret = []
|
let ret = []
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
const select = {addSelect, options}
|
const select = {addSelect, options}
|
||||||
|
|
@ -1345,7 +1399,7 @@ ReactiveMiniMongoIndex = {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
getChecklistsWithCardId(cardId, addSelect = {}, options) {
|
getChecklistsWithCardId(cardId, addSelect = {}, options = {}) {
|
||||||
let ret = []
|
let ret = []
|
||||||
if (cardId) {
|
if (cardId) {
|
||||||
const select = {addSelect, options}
|
const select = {addSelect, options}
|
||||||
|
|
@ -1367,7 +1421,7 @@ ReactiveMiniMongoIndex = {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
getChecklistItemsWithChecklistId(checklistId, addSelect = {}, options) {
|
getChecklistItemsWithChecklistId(checklistId, addSelect = {}, options = {}) {
|
||||||
let ret = []
|
let ret = []
|
||||||
if (checklistId) {
|
if (checklistId) {
|
||||||
const select = {addSelect, options}
|
const select = {addSelect, options}
|
||||||
|
|
@ -1384,12 +1438,18 @@ ReactiveMiniMongoIndex = {
|
||||||
}
|
}
|
||||||
ret = this.__checklistItemsWithId.get(EJSON.stringify(select));
|
ret = this.__checklistItemsWithId.get(EJSON.stringify(select));
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret[checklistId] = ReactiveCache.getChecklistItems(
|
||||||
|
{checklistId: checklistId,
|
||||||
|
...addSelect
|
||||||
|
}, options);
|
||||||
|
}
|
||||||
ret = ret[checklistId] || [];
|
ret = ret[checklistId] || [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
getCardCommentsWithCardId(cardId, addSelect = {}, options) {
|
getCardCommentsWithCardId(cardId, addSelect = {}, options = {}) {
|
||||||
let ret = []
|
let ret = []
|
||||||
if (cardId) {
|
if (cardId) {
|
||||||
const select = {addSelect, options}
|
const select = {addSelect, options}
|
||||||
|
|
@ -1411,7 +1471,7 @@ ReactiveMiniMongoIndex = {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
getActivityWithId(activityId, addSelect = {}, options) {
|
getActivityWithId(activityId, addSelect = {}, options = {}) {
|
||||||
let ret = []
|
let ret = []
|
||||||
if (activityId) {
|
if (activityId) {
|
||||||
const select = {addSelect, options}
|
const select = {addSelect, options}
|
||||||
|
|
@ -1435,4 +1495,58 @@ ReactiveMiniMongoIndex = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// global Reactive MiniMongo Index Cache class to avoid big overhead while searching for the same data often again
|
||||||
|
// This class calls 2 implementation, for server and client code
|
||||||
|
//
|
||||||
|
// having this class here has several advantages:
|
||||||
|
// - The Programmer hasn't to care about in which context he call's this class
|
||||||
|
// - having all queries together in 1 class to make it possible to see which queries in Wekan happens, e.g. with console.log
|
||||||
|
ReactiveMiniMongoIndex = {
|
||||||
|
getSubTasksWithParentId(parentId, addSelect = {}, options = {}) {
|
||||||
|
let ret;
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret = ReactiveMiniMongoIndexServer.getSubTasksWithParentId(parentId, addSelect, options);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveMiniMongoIndexClient.getSubTasksWithParentId(parentId, addSelect, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getChecklistsWithCardId(cardId, addSelect = {}, options = {}) {
|
||||||
|
let ret;
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret = ReactiveMiniMongoIndexServer.getChecklistsWithCardId(cardId, addSelect, options);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveMiniMongoIndexClient.getChecklistsWithCardId(cardId, addSelect, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getChecklistItemsWithChecklistId(checklistId, addSelect = {}, options = {}) {
|
||||||
|
let ret;
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret = ReactiveMiniMongoIndexServer.getChecklistItemsWithChecklistId(checklistId, addSelect, options);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveMiniMongoIndexClient.getChecklistItemsWithChecklistId(checklistId, addSelect, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getCardCommentsWithCardId(cardId, addSelect = {}, options = {}) {
|
||||||
|
let ret;
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret = ReactiveMiniMongoIndexServer.getCardCommentsWithCardId(cardId, addSelect, options);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveMiniMongoIndexClient.getCardCommentsWithCardId(cardId, addSelect, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getActivityWithId(activityId, addSelect = {}, options = {}) {
|
||||||
|
let ret;
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret = ReactiveMiniMongoIndexServer.getActivityWithId(activityId, addSelect, options);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveMiniMongoIndexClient.getActivityWithId(activityId, addSelect, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export { ReactiveCache, ReactiveMiniMongoIndex };
|
export { ReactiveCache, ReactiveMiniMongoIndex };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue