removed concurrency from generation script
This commit is contained in:
parent
fc8f6e3066
commit
86db797765
37
generate.js
37
generate.js
@ -696,7 +696,7 @@ const processRecords = async () => {
|
||||
const stateFn = pug.compileFile(singleStateTmpl);
|
||||
const countyFn = pug.compileFile(singleCountyTmpl);
|
||||
|
||||
await Promise.all(countryArr.map(async (countryData) => {
|
||||
for (const countryData of countryArr) {
|
||||
const start = Date.now();
|
||||
const targetFile = path.join(publicDir, 'countries', countryData.safeName + '.html');
|
||||
const countryHtml = countryFn({
|
||||
@ -704,29 +704,9 @@ const processRecords = async () => {
|
||||
$title: countryData.name,
|
||||
lastUpdate,
|
||||
});
|
||||
console.log(`writing to ${targetFile}`);
|
||||
await promiseMe(callback => fs.writeFile(targetFile, countryHtml, callback));
|
||||
console.log(`wrote to ${targetFile} in ${Date.now() - start}ms`);
|
||||
console.log(`[country:${countryData.name}] wrote to ${targetFile} in ${Date.now() - start}ms`);
|
||||
|
||||
if (countryData.states.length) {
|
||||
await Promise.all(countryData.states.map(async (stateData) => {
|
||||
if (!stateData.name || !stateData.counties || !stateData.counties.length) {
|
||||
return;
|
||||
}
|
||||
const start = Date.now();
|
||||
const targetFile = path.join(publicDir, 'countries', countryData.safeName + '-' + stateData.safeName + '.html');
|
||||
const stateHtml = stateFn({
|
||||
data: stateData,
|
||||
$title: stateData.name + ' - ' + countryData.name,
|
||||
lastUpdate,
|
||||
});
|
||||
await promiseMe(callback => fs.writeFile(targetFile, stateHtml, callback));
|
||||
console.log(`wrote to ${targetFile} in ${Date.now() - start}ms`);
|
||||
}));
|
||||
}
|
||||
}));
|
||||
|
||||
for (const countryData of countryArr) {
|
||||
if (!countryData.states) {
|
||||
continue;
|
||||
}
|
||||
@ -735,6 +715,17 @@ const processRecords = async () => {
|
||||
if (!stateData.name || !stateData.counties || !stateData.counties.length) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const start = Date.now();
|
||||
const targetFile = path.join(publicDir, 'countries', countryData.safeName + '-' + stateData.safeName + '.html');
|
||||
const stateHtml = stateFn({
|
||||
data: stateData,
|
||||
$title: stateData.name + ', ' + countryData.name,
|
||||
lastUpdate,
|
||||
});
|
||||
await promiseMe(callback => fs.writeFile(targetFile, stateHtml, callback));
|
||||
console.log(`[state:${stateData.name}] wrote to ${targetFile} in ${Date.now() - start}ms`);
|
||||
|
||||
for (const countyData of stateData.counties) {
|
||||
countyData.population = countyData.population || 0;
|
||||
|
||||
@ -750,7 +741,7 @@ const processRecords = async () => {
|
||||
lastUpdate,
|
||||
});
|
||||
await promiseMe(callback => fs.writeFile(targetFile, countyHtml, callback));
|
||||
console.log(`wrote to ${targetFile} in ${Date.now() - start}ms`);
|
||||
console.log(`[county:${countyData.state}-${countyData.name}] wrote to ${targetFile} in ${Date.now() - start}ms`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user