mirror of
https://github.com/wekan/wekan.git
synced 2025-12-18 00:10:13 +01:00
Move every Integrations.findOne(idOrFirstObjectSelector, options) to the ReactiveCache
This commit is contained in:
parent
767d8e66e7
commit
6b7b464acc
4 changed files with 55 additions and 5 deletions
|
|
@ -437,7 +437,7 @@ BlazeComponent.extendComponent({
|
||||||
for (const k in condition) {
|
for (const k in condition) {
|
||||||
if (!condition[k]) delete condition[k];
|
if (!condition[k]) delete condition[k];
|
||||||
}
|
}
|
||||||
return Integrations.findOne(condition);
|
return ReactiveCache.getIntegration(condition);
|
||||||
},
|
},
|
||||||
onCreated() {
|
onCreated() {
|
||||||
this.disabled = new ReactiveVar(false);
|
this.disabled = new ReactiveVar(false);
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,14 @@ ReactiveCacheServer = {
|
||||||
const ret = ImpersonatedUsers.find(selector, options).fetch();
|
const ret = ImpersonatedUsers.find(selector, options).fetch();
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
getIntegration(idOrFirstObjectSelector, options) {
|
||||||
|
const ret = Integrations.findOne(idOrFirstObjectSelector, options);
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getIntegrations(selector, options) {
|
||||||
|
const ret = Integrations.find(selector, options).fetch();
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
getCurrentSetting() {
|
getCurrentSetting() {
|
||||||
const ret = Settings.findOne();
|
const ret = Settings.findOne();
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -593,6 +601,30 @@ ReactiveCacheClient = {
|
||||||
const ret = this.__impersonatedUsers.get(Jsons.stringify(select));
|
const ret = this.__impersonatedUsers.get(Jsons.stringify(select));
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
getIntegration(idOrFirstObjectSelector, options) {
|
||||||
|
const idOrFirstObjectSelect = {idOrFirstObjectSelector, options}
|
||||||
|
if (!this.__integration) {
|
||||||
|
this.__integration = new DataCache(_idOrFirstObjectSelect => {
|
||||||
|
const __select = Jsons.parse(_idOrFirstObjectSelect);
|
||||||
|
const _ret = Integrations.findOne(__select.idOrFirstObjectSelector, __select.options);
|
||||||
|
return _ret;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const ret = this.__integration.get(Jsons.stringify(idOrFirstObjectSelect));
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getIntegrations(selector, options) {
|
||||||
|
const select = {selector, options}
|
||||||
|
if (!this.__integrations) {
|
||||||
|
this.__integrations = new DataCache(_select => {
|
||||||
|
const __select = Jsons.parse(_select);
|
||||||
|
const _ret = Integrations.find(__select.selector, __select.options).fetch();
|
||||||
|
return _ret;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const ret = this.__integrations.get(Jsons.stringify(select));
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
getCurrentSetting() {
|
getCurrentSetting() {
|
||||||
if (!this.__currentSetting || !this.__currentSetting.get()) {
|
if (!this.__currentSetting || !this.__currentSetting.get()) {
|
||||||
this.__currentSetting = new DataCache(() => {
|
this.__currentSetting = new DataCache(() => {
|
||||||
|
|
@ -946,6 +978,24 @@ ReactiveCache = {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
getIntegration(idOrFirstObjectSelector, options) {
|
||||||
|
let ret;
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret = ReactiveCacheServer.getIntegration(idOrFirstObjectSelector, options);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveCacheClient.getIntegration(idOrFirstObjectSelector, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getIntegrations(selector, options) {
|
||||||
|
let ret;
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret = ReactiveCacheServer.getIntegrations(selector, options);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveCacheClient.getIntegrations(selector, options);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
getCurrentSetting() {
|
getCurrentSetting() {
|
||||||
let ret;
|
let ret;
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ if (Meteor.isServer) {
|
||||||
|
|
||||||
JsonRoutes.sendResult(res, {
|
JsonRoutes.sendResult(res, {
|
||||||
code: 200,
|
code: 200,
|
||||||
data: Integrations.findOne(
|
data: ReactiveCache.getIntegration(
|
||||||
{ _id: paramIntId, boardId: paramBoardId },
|
{ _id: paramIntId, boardId: paramBoardId },
|
||||||
{ fields: { token: 0 } },
|
{ fields: { token: 0 } },
|
||||||
),
|
),
|
||||||
|
|
@ -324,7 +324,7 @@ if (Meteor.isServer) {
|
||||||
|
|
||||||
JsonRoutes.sendResult(res, {
|
JsonRoutes.sendResult(res, {
|
||||||
code: 200,
|
code: 200,
|
||||||
data: Integrations.findOne(
|
data: ReactiveCache.getIntegration(
|
||||||
{ _id: paramIntId, boardId: paramBoardId },
|
{ _id: paramIntId, boardId: paramBoardId },
|
||||||
{ fields: { _id: 1, activities: 1 } },
|
{ fields: { _id: 1, activities: 1 } },
|
||||||
),
|
),
|
||||||
|
|
@ -364,7 +364,7 @@ if (Meteor.isServer) {
|
||||||
|
|
||||||
JsonRoutes.sendResult(res, {
|
JsonRoutes.sendResult(res, {
|
||||||
code: 200,
|
code: 200,
|
||||||
data: Integrations.findOne(
|
data: ReactiveCache.getIntegration(
|
||||||
{ _id: paramIntId, boardId: paramBoardId },
|
{ _id: paramIntId, boardId: paramBoardId },
|
||||||
{ fields: { _id: 1, activities: 1 } },
|
{ fields: { _id: 1, activities: 1 } },
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ if (Meteor.isServer) {
|
||||||
data: is2way ? { description, ...clonedParams } : value,
|
data: is2way ? { description, ...clonedParams } : value,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!Integrations.findOne({ url: integration.url })) return;
|
if (!ReactiveCache.getIntegration({ url: integration.url })) return;
|
||||||
|
|
||||||
const url = integration.url;
|
const url = integration.url;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue