Started adding async calls for upgrading to Meteor 3.0. Numerous other fixes.

This commit is contained in:
2025-07-02 11:18:09 -07:00
parent e1216741d6
commit 2e99ad007c
32 changed files with 549 additions and 373 deletions

View File

@@ -66,7 +66,7 @@ if(Meteor.isServer) {
}
}]);
result.toArray().then(function(result) {
result.toArray().then(async function(result) {
let totalByYear = {};
//Create a map of maps: year -> measure id -> sales count.
@@ -80,7 +80,7 @@ if(Meteor.isServer) {
}
//Create a list of ordered measures. We could use a map, but then getting the ordering correct would be difficult.
let measures = Meteor.collections.Measures.find({}, {fields: {_id: 1, name: 1}, sort: {order: 1}}).fetch();
let measures = await Meteor.collections.Measures.find({}, {fields: {_id: 1, name: 1}, sort: {order: 1}}).fetchAsync();
//Collect the years in ascending oder.
let years = Object.keys(totalByYear).sort(function(a, b) {return parseInt(a) - parseInt(b);});
@@ -130,7 +130,7 @@ if(Meteor.isServer) {
}
}]);
result.toArray().then(function(result) {
result.toArray().then(async function(result) {
let productSalesTotalsMapByYear = {};
//Create a map of maps: year -> product id -> sales totals.
@@ -145,7 +145,7 @@ if(Meteor.isServer) {
//Now create a mapping between the tag id's and tag names for later use.
let tagIdToTagNameMap = {};
let tags = Meteor.collections.ProductTags.find({}, {fields: {_id: 1, name: 1}}).fetch();
let tags = await Meteor.collections.ProductTags.find({}, {fields: {_id: 1, name: 1}}).fetchAsync();
for(let tag of tags) {
tagIdToTagNameMap[tag._id] = tag.name;
@@ -153,7 +153,7 @@ if(Meteor.isServer) {
//Now create a map between tag names -> [product ids] so that we can build a table below.
let tagProductIdsMap = {};
let products = Meteor.collections.Products.find({}, {fields: {_id: 1, tags: 1}}).fetch();
let products = await Meteor.collections.Products.find({}, {fields: {_id: 1, tags: 1}}).fetchAsync();
for(let product of products) {
for(let tagId of product.tags) {
@@ -234,7 +234,7 @@ if(Meteor.isServer) {
}
}]);
result.toArray().then(function(result) {
result.toArray().then(async function(result) {
let totalByYear = {};
//Create a map of maps: year -> product id -> measure id -> sales count.
@@ -252,10 +252,10 @@ if(Meteor.isServer) {
}
//Create a list of ordered measures. We could use a map, but then getting the ordering correct would be difficult.
let measures = Meteor.collections.Measures.find({}, {fields: {_id: 1, name: 1}, sort: {order: 1}}).fetch();
let measures = await Meteor.collections.Measures.find({}, {fields: {_id: 1, name: 1}, sort: {order: 1}}).fetcAsync();
//Now create a mapping between the product id's and product names for later use.
let products = Meteor.collections.Products.find({}, {fields: {_id: 1, name: 1}, sort: {name: 1}}).fetch();
let products = await Meteor.collections.Products.find({}, {fields: {_id: 1, name: 1}, sort: {name: 1}}).fetcAsync();
//Collect the years in ascending oder.
let years = Object.keys(totalByYear).sort(function(a, b) {return parseInt(a) - parseInt(b);});
@@ -367,7 +367,7 @@ if(Meteor.isServer) {
}
}]);
result.toArray().then(function(result) {
result.toArray().then(async function(result) {
let totalByYear = {};
//Create a map of maps: year -> product id -> measure id -> sales count.
@@ -385,11 +385,11 @@ if(Meteor.isServer) {
}
//Create a list of ordered measures. We could use a map, but then getting the ordering correct would be difficult.
let measures = Meteor.collections.Measures.find({}, {fields: {_id: 1, name: 1}, sort: {order: 1}}).fetch();
let measures = await Meteor.collections.Measures.find({}, {fields: {_id: 1, name: 1}, sort: {order: 1}}).fetcAsync();
//Now create a mapping between the tag id's and tag names for later use.
let tagIdToTagNameMap = {};
let tags = Meteor.collections.ProductTags.find({}, {fields: {_id: 1, name: 1}}).fetch();
let tags = await Meteor.collections.ProductTags.find({}, {fields: {_id: 1, name: 1}}).fetcAsync();
for(let tag of tags) {
tagIdToTagNameMap[tag._id] = tag.name;
@@ -397,7 +397,7 @@ if(Meteor.isServer) {
//Now create a map between tag names -> [product ids] so that we can build a table below.
let tagProductIdsMap = {};
let products = Meteor.collections.Products.find({}, {fields: {_id: 1, tags: 1}}).fetch();
let products = await Meteor.collections.Products.find({}, {fields: {_id: 1, tags: 1}}).fetcAsync();
for(let product of products) {
for(let tagId of product.tags) {