Improved character subscription performance

By limiting fields that can trigger an autorun
This commit is contained in:
Stefan Zermatten
2022-05-11 15:52:44 +02:00
parent 6702f431d0
commit ccc861b6fa

View File

@@ -20,12 +20,18 @@ Meteor.publish('singleCharacter', function(creatureId){
this.error(e);
}
this.autorun(function (computation){
let userId = this.userId;
let creatureCursor
creatureCursor = Creatures.find({
const userId = this.userId;
const creature = Creatures.findOne({
_id: creatureId,
}, {
fields: {
owner: 1,
readers: 1,
writers: 1,
public: 1,
computeVersion: 1,
}
});
let creature = creatureCursor.fetch()[0];
try { assertViewPermission(creature, userId) }
catch(e){ return [] }
if (creature.computeVersion !== VERSION && computation.firstRun){
@@ -35,7 +41,9 @@ Meteor.publish('singleCharacter', function(creatureId){
catch(e){ console.error(e) }
}
return [
creatureCursor,
Creatures.find({
_id: creatureId,
}),
CreatureProperties.find({
'ancestors.id': creatureId,
}),