You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

48 lines
1.3 KiB

'use strict';
(function() {
var stations = require('./server/stations');
var meteo = require('./server/meteo');
var assemble = require('./server/assemble');
var IO = require('./server/io');
var chalk = require('chalk');
/**
* Iteration based flow.
*/
function next(index) {
if (index >= stations.ids.length) {
console.log(chalk.green("Finished."));
return;
}
console.log('=== Starting next promise chain.');
var station = stations.ids[index];
Promise.resolve()
//===== Download
// .then(stations.getMetadata.bind(null, station))
// .then(meteo.getAllYears.bind(null, station, 1982, 2014))
// .then(meteo.getAllMonths.bind(null, station, 2015))
// .then(meteo.getAllNewest.bind(null, station, 2015))
//===== Parse and write JSON years files
// .then(stations.parseStation.bind(null, station))
// .then(meteo.parseAllMonths.bind(null, station, 2015))
// .then(meteo.parseAllYears.bind(null, station, 1982, 2014))
//===== Flow control
// .then(next.bind(null, index + 1))
.catch(IO.error);
};
// next(0);
/**
* Final assembly of file for client.
*/
assemble.buildFinalJson();
})();