diff --git a/src/ckdb.h b/src/ckdb.h index 6a3bc10f..d4d54a1c 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -55,7 +55,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.0" -#define CKDB_VERSION DB_VERSION"-1.101" +#define CKDB_VERSION DB_VERSION"-1.103" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ @@ -105,6 +105,9 @@ extern int switch_state; #define BLANK " " extern char *EMPTY; +// To ensure there's space for the ticker +#define TICK_PREFIX " " + // Field patterns extern const char *userpatt; extern const char *mailpatt; diff --git a/src/ckdb_dbio.c b/src/ckdb_dbio.c index 3a251aa4..c209ea76 100644 --- a/src/ckdb_dbio.c +++ b/src/ckdb_dbio.c @@ -9,6 +9,17 @@ #include "ckdb.h" +// Doesn't work with negative numbers ... +void pcom(int n) +{ + if (n < 1000) + printf("%d", n); + else { + pcom(n/1000); + printf(",%03d", n % 1000); + } +} + char *pqerrmsg(PGconn *conn) { char *ptr, *buf = strdup(PQerrorMessage(conn)); @@ -2624,6 +2635,9 @@ bool workinfo_fill(PGconn *conn) LOGDEBUG("%s(): select", __func__); + printf(TICK_PREFIX"wi 0\r"); + fflush(stdout); + // TODO: select the data based on sharesummary since old data isn't needed // however, the ageing rules for workinfo will decide that also // keep the last block + current? Rules will depend on payout scheme also @@ -2765,6 +2779,13 @@ bool workinfo_fill(PGconn *conn) dbstatus.newest_workinfoid = row->workinfoid; } + if (i == 0 || ((i+1) % 100000) == 0) { + printf(TICK_PREFIX"wi "); + pcom(i+1); + putchar('\r'); + fflush(stdout); + } + tick(); } if (!ok) { @@ -5896,6 +5917,9 @@ bool markersummary_fill(PGconn *conn) LOGDEBUG("%s(): select", __func__); + printf(TICK_PREFIX"ms 0\r"); + fflush(stdout); + // TODO: limit how far back sel = "select " "markerid,userid,workername,diffacc,diffsta,diffdup,diffhi," @@ -6055,6 +6079,13 @@ bool markersummary_fill(PGconn *conn) _userinfo_update(NULL, NULL, row, false, false); + if (i == 0 || ((i+1) % 100000) == 0) { + printf(TICK_PREFIX"ms "); + pcom(i+1); + putchar('\r'); + fflush(stdout); + } + tick(); } if (!ok) {