meteor3: web Fires publications to async (findOneAsync/countAsync/awaited firesUnion)
fireFromId, fireFromAlertId, fireFromActiveId and fireFromHash now use the async collection APIs and async publish handlers (so try/catch catches rejections). falsePositivesMyloc/industriesMyloc/comments.forReference are cursor-only and needed no change. Verified over raw DDP against the seeded dev Mongo 7; REST smoke stays byte-identical (12/12).
This commit is contained in:
parent
48d33c397b
commit
feaf66fe34
2 changed files with 24 additions and 14 deletions
|
|
@ -76,14 +76,14 @@ const findOrCreateFire = async (obj) => {
|
|||
return findFire(obj);
|
||||
};
|
||||
|
||||
Meteor.publish('fireFromAlertId', function fireFromAlertId(_id) {
|
||||
Meteor.publish('fireFromAlertId', async function fireFromAlertId(_id) {
|
||||
try {
|
||||
check(_id, String);
|
||||
// console.log(`Looking for alert fire ${_id}`);
|
||||
const fire = FireAlertsCollection.findOne(new Meteor.Collection.ObjectID(_id));
|
||||
const fire = await FireAlertsCollection.findOneAsync(new Meteor.Collection.ObjectID(_id));
|
||||
if (fire) {
|
||||
// console.info(`Active fire found: ${_id}`);
|
||||
return findOrCreateFire(fixConfidence(fire));
|
||||
return await findOrCreateFire(fixConfidence(fire));
|
||||
}
|
||||
console.info(`Alert fire not found: ${_id}`);
|
||||
// Not found in active fires!
|
||||
|
|
@ -94,14 +94,14 @@ Meteor.publish('fireFromAlertId', function fireFromAlertId(_id) {
|
|||
}
|
||||
});
|
||||
|
||||
Meteor.publish('fireFromActiveId', function fireFromActiveId(_id) {
|
||||
Meteor.publish('fireFromActiveId', async function fireFromActiveId(_id) {
|
||||
try {
|
||||
check(_id, String);
|
||||
// console.log(`Looking for active fire ${_id}`);
|
||||
const fire = ActiveFiresCollection.findOne(new Meteor.Collection.ObjectID(_id));
|
||||
const fire = await ActiveFiresCollection.findOneAsync(new Meteor.Collection.ObjectID(_id));
|
||||
if (fire) {
|
||||
// console.info(`Active fire found: ${_id}`);
|
||||
return findOrCreateFire(fixConfidence(fire));
|
||||
return await findOrCreateFire(fixConfidence(fire));
|
||||
}
|
||||
console.info(`Active fire not found: ${_id}`);
|
||||
// Not found in active fires!
|
||||
|
|
@ -112,14 +112,14 @@ Meteor.publish('fireFromActiveId', function fireFromActiveId(_id) {
|
|||
}
|
||||
});
|
||||
|
||||
Meteor.publish('fireFromId', function fireFromId(_id) {
|
||||
Meteor.publish('fireFromId', async function fireFromId(_id) {
|
||||
try {
|
||||
check(_id, String);
|
||||
// console.log(`Looking for archive fire ${_id}`);
|
||||
const fire = FiresCollection.find(new Meteor.Collection.ObjectID(_id));
|
||||
if (fire.count() !== 0) {
|
||||
if (await fire.countAsync() !== 0) {
|
||||
// console.info(`Archive fire found: ${_id}`);
|
||||
const union = firesUnion(fire);
|
||||
const union = await firesUnion(fire);
|
||||
const falsePos = whichAreFalsePositives(FalsePositives, union);
|
||||
const industries = whichAreFalsePositives(Industries, union);
|
||||
return [fire, falsePos, industries];
|
||||
|
|
@ -163,11 +163,11 @@ export async function fireFromHash(fireEnc, params) {
|
|||
* return fire; */
|
||||
}
|
||||
|
||||
Meteor.publish('fireFromHash', function fireFromHashFunc(fireEnc, params) {
|
||||
Meteor.publish('fireFromHash', async function fireFromHashFunc(fireEnc, params) {
|
||||
check(fireEnc, String);
|
||||
check(params, Object);
|
||||
try {
|
||||
return fireFromHash(fireEnc, params);
|
||||
return await fireFromHash(fireEnc, params);
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
logUrl(fireEnc, params);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue