From e7c5d1ec826bf23796b3c9edb890e8205902b6ad Mon Sep 17 00:00:00 2001 From: kanoi Date: Sat, 29 Aug 2015 20:58:28 +1000 Subject: [PATCH] ckdb/php - add age to block stats table --- pool/base.php | 48 ++++++++++++++++++++++++++++++++++++++++++++ pool/page_blocks.php | 3 +++ src/ckdb.h | 2 +- src/ckdb_cmd.c | 7 ++++++- 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/pool/base.php b/pool/base.php index e388a538..7c88113c 100644 --- a/pool/base.php +++ b/pool/base.php @@ -28,6 +28,54 @@ function dq($str) return str_replace('"', "\\\"", $str); } # +function daysago($val) +{ + if ($val < -13) + return ''; + + if ($val < 60) + $des = $val.'s'; + else + { + $val = round($val/6)/10; + if ($val < 60) + $des = $val.'min'; + else + { + $val = round($val/6)/10; + if ($val < 24) + { + $des = $val.'hr'; + if ($val != 1) + $des .= 's'; + } + else + { + $val = round($val/2.4)/10; + if ($val < 100) + { + $des = $val.'day'; + if ($val != 1) + $des .= 's'; + } + else + { + $val = round($val/0.7)/10; + if ($val < 10000) + { + $des = $val.'wk'; + if ($val != 1) + $des .= 's'; + } + else + $des = ''; + } + } + } + } + return $des; +} +# function howlongago($sec) { if ($sec < 60) diff --git a/pool/page_blocks.php b/pool/page_blocks.php index 68d04704..167f2999 100644 --- a/pool/page_blocks.php +++ b/pool/page_blocks.php @@ -93,6 +93,7 @@ function doblocks($data, $user) $pg .= "\n"; $pg .= ""; $pg .= ""; + $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; @@ -108,6 +109,7 @@ function doblocks($data, $user) $row = 'odd'; $desc = $ans['s_desc:'.$i]; + $age = daysago($ans['STAMP'] - $ans['s_createdate:'.$i]); $diff = number_format(100 * $ans['s_diffratio:'.$i], 2); $mean = number_format(100 * $ans['s_diffmean:'.$i], 2); @@ -120,6 +122,7 @@ function doblocks($data, $user) $pg .= ""; $pg .= ""; + $pg .= ""; $pg .= ""; $pg .= ""; $pg .= ""; diff --git a/src/ckdb.h b/src/ckdb.h index c0f1eaec..b6cfd070 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -55,7 +55,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.2" -#define CKDB_VERSION DB_VERSION"-1.226" +#define CKDB_VERSION DB_VERSION"-1.227" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index 02ee883e..5f749d3f 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -1303,12 +1303,16 @@ redo: snprintf(tmp, sizeof(tmp), "s_seq:%d=%d%c" "s_desc:%d=%s%c" + "s_height:%d=%d%c" + "s_"CDTRF":%d=%ld%c" "s_diffratio:%d=%.8f%c" "s_diffmean:%d=%.8f%c" "s_cdferl:%d=%.8f%c" "s_luck:%d=%.8f%c", srows, seq, FLDSEP, srows, desc, FLDSEP, + srows, (int)(blocks->height), FLDSEP, + srows, blocks->createdate.tv_sec, FLDSEP, srows, blocks->diffratio, FLDSEP, srows, blocks->diffmean, FLDSEP, srows, blocks->cdferl, FLDSEP, @@ -1340,7 +1344,8 @@ redo: snprintf(tmp, sizeof(tmp), "s_rows=%d%cs_flds=%s%c", srows, FLDSEP, - "s_seq,s_desc,s_diffratio,s_diffmean,s_cdferl,s_luck", + "s_seq,s_desc,s_height,s_"CDTRF",s_diffratio,s_diffmean," + "s_cdferl,s_luck", FLDSEP); APPEND_REALLOC(buf, off, len, tmp);
DescriptionAgeDiff%Mean%CDF[Erl]
$desc Blocks$age$diff%$mean%$cdferldsp