diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-04-23 11:12:05 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-04-23 11:12:05 +0200 |
| commit | bc6afda731eb388471fe2499e1af99932cd2fba8 (patch) | |
| tree | 3bfb25e9a4ff223a3a89e822ed9b517c4ae2c730 | |
| parent | b001f9cde6d945d3d2690767b60d60ef7c914613 (diff) | |
| download | cruncher-bc6afda731eb388471fe2499e1af99932cd2fba8.tar.gz cruncher-bc6afda731eb388471fe2499e1af99932cd2fba8.zip | |
add progress to global stats
| -rw-r--r-- | worker.js | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -199,17 +199,20 @@ function* chunks(arr) { async function calculate_global_point() { logger.info("crunching global stats, this could take a while"); await seq.transaction({ autocommit: false }, async (transaction) => { - await Promise.map(global_points, async (tuple) => { - const where_aggr = tuple[0], where_links = tuple[1]; + await Promise.map(global_points, async (tuple, idx, len) => { + const progress = Math.floor(100*100 * (1-idx/len)) / 100, + where_aggr = tuple[0], where_links = tuple[1]; // aggregate participant_stats with our condition let stats = await aggregate_stats(where_aggr); if (stats != undefined) { stats.updated_at = seq.fn("NOW"); - logger.info("inserting global stat"); + logger.info("inserting global stat", + { progress: progress }); Object.assign(stats, where_links); await model.GlobalPoint.upsert(stats, { transaction: transaction }); - } else logger.warn("not enough data for this global stat!"); + } else logger.warn("not enough data for this global stat!", + { progress: progress }); }, { concurrency: MAXCONNS }); }); logger.info("committing"); |
