From bc19c266b9ae1e4808ba7c7fafd0200c1c5413f8 Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 31 Jul 2014 22:48:49 +1000 Subject: [PATCH] ckdb - correct summarisation --- src/ckdb.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/ckdb.c b/src/ckdb.c index 3ec8ff45..f4279f67 100644 --- a/src/ckdb.c +++ b/src/ckdb.c @@ -4559,7 +4559,7 @@ static bool userstats_add_db(PGconn *conn, USERSTATS *row) PGresult *res; char *ins; bool ok = false; - char *params[9 + HISTORYDATECOUNT]; + char *params[9 + SIMPLEDATECOUNT]; int par; int n; @@ -6671,27 +6671,27 @@ static void summarise_userstats() count = 1; while (next) { - if (DATA_USERSTATS(next)->userid != userstats->userid) - break; - if (strcmp(DATA_USERSTATS(next)->workername, userstats->workername)) - break; statrange = tvdiff(&when, &(DATA_USERSTATS(next)->statsdate)); if (statrange <= 0) break; - count++; - userstats->hashrate += DATA_USERSTATS(next)->hashrate; - userstats->hashrate5m += DATA_USERSTATS(next)->hashrate5m; - userstats->hashrate1hr += DATA_USERSTATS(next)->hashrate1hr; - userstats->hashrate24hr += DATA_USERSTATS(next)->hashrate24hr; - if (userstats->elapsed > DATA_USERSTATS(next)->elapsed) - userstats->elapsed = DATA_USERSTATS(next)->elapsed; - tmp = next_in_ktree(ctx); - remove_from_ktree(userstats_root, next, cmp_userstats, ctx2); - remove_from_ktree(userstats_statsdate_root, next, cmp_userstats_statsdate, ctx2); - k_unlink_item(userstats_store, next); - k_add_head(userstats_summ, next); + + if (DATA_USERSTATS(next)->userid == userstats->userid && + strcmp(DATA_USERSTATS(next)->workername, userstats->workername)) { + count++; + userstats->hashrate += DATA_USERSTATS(next)->hashrate; + userstats->hashrate5m += DATA_USERSTATS(next)->hashrate5m; + userstats->hashrate1hr += DATA_USERSTATS(next)->hashrate1hr; + userstats->hashrate24hr += DATA_USERSTATS(next)->hashrate24hr; + if (userstats->elapsed > DATA_USERSTATS(next)->elapsed) + userstats->elapsed = DATA_USERSTATS(next)->elapsed; + + remove_from_ktree(userstats_root, next, cmp_userstats, ctx2); + remove_from_ktree(userstats_statsdate_root, next, cmp_userstats_statsdate, ctx2); + k_unlink_item(userstats_store, next); + k_add_head(userstats_summ, next); + } next = tmp; }