Browse Source

ckdb - start of v0.4 changes

master
kanoi 11 years ago
parent
commit
1f2072c58c
  1. 3
      sql/ckdb.sql
  2. 28
      sql/v0.3-v0.4.sql
  3. 10
      src/ckdb.c

3
sql/ckdb.sql

@ -374,6 +374,7 @@ CREATE TABLE userstats (
hashrate5m float NOT NULL, hashrate5m float NOT NULL,
hashrate1hr float NOT NULL, hashrate1hr float NOT NULL,
hashrate24hr float NOT NULL, hashrate24hr float NOT NULL,
summarylevel char NOT NULL,
createdate timestamp with time zone NOT NULL, createdate timestamp with time zone NOT NULL,
createby character varying(64) DEFAULT ''::character varying NOT NULL, createby character varying(64) DEFAULT ''::character varying NOT NULL,
createcode character varying(128) DEFAULT ''::character varying NOT NULL, createcode character varying(128) DEFAULT ''::character varying NOT NULL,
@ -388,4 +389,4 @@ CREATE TABLE version (
PRIMARY KEY (vlock) PRIMARY KEY (vlock)
); );
insert into version (vlock,version) values (1,'0.3'); insert into version (vlock,version) values (1,'0.4');

28
sql/v0.3-v0.4.sql

@ -0,0 +1,28 @@
SET SESSION AUTHORIZATION 'postgres';
BEGIN transaction;
DO $$
DECLARE ver TEXT;
BEGIN
UPDATE version set version='0.4' where vlock=1 and version='0.3';
IF found THEN
RETURN;
END IF;
SELECT version into ver from version
WHERE vlock=1;
RAISE EXCEPTION 'Wrong DB version - expect "0.3" - found "%"', ver;
END $$;
ALTER TABLE ONLY userstats
ADD COLUMN summarylevel char DEFAULT ' ' NOT NULL;
ALTER TABLE ONLY userstats
ALTER COLUMN summarylevel DROP DEFAULT;
END transaction;

10
src/ckdb.c

@ -41,7 +41,7 @@
// will need to be if threading is added // will need to be if threading is added
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "0.3" #define DB_VERSION "0.4"
#define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -936,7 +936,7 @@ typedef struct userstats {
double hashrate1hr; double hashrate1hr;
double hashrate24hr; double hashrate24hr;
bool idle; // Non-db field bool idle; // Non-db field
char summarylevel[TXT_FLAG+1]; // Initially '0' in the DB char summarylevel[TXT_FLAG+1]; // Initially SUMMARY_NONE
SIMPLEDATECONTROLFIELDS; SIMPLEDATECONTROLFIELDS;
} USERSTATS; } USERSTATS;
@ -964,6 +964,10 @@ static K_STORE *userstats_eos_store;
/* on the allusers page, show any with stats in the last ... */ /* on the allusers page, show any with stats in the last ... */
#define ALLUSERS_LIMIT_S 3600 #define ALLUSERS_LIMIT_S 3600
#define SUMMARY_NONE '0'
#define SUMMARY_DB '1'
#define SUMMARY_FULL '2'
/* Userstats get stored in the DB for each time band of this /* Userstats get stored in the DB for each time band of this
* amount from midnight (UTC+00) * amount from midnight (UTC+00)
* Thus we simply put each stats value in the time band of the * Thus we simply put each stats value in the time band of the
@ -4418,6 +4422,8 @@ static bool userstats_add(char *poolinstance, char *elapsed, char *username,
TXT_TO_DOUBLE("hashrate1hr", hashrate1hr, row->hashrate1hr); TXT_TO_DOUBLE("hashrate1hr", hashrate1hr, row->hashrate1hr);
TXT_TO_DOUBLE("hashrate24hr", hashrate24hr, row->hashrate24hr); TXT_TO_DOUBLE("hashrate24hr", hashrate24hr, row->hashrate24hr);
row->idle = idle; row->idle = idle;
row->summarylevel[0] = SUMMARY_NONE;
row->summarylevel[1] = '\0';
SIMPLEDATEINIT(row, now, by, code, inet); SIMPLEDATEINIT(row, now, by, code, inet);
SIMPLEDATETRANSFER(row); SIMPLEDATETRANSFER(row);

Loading…
Cancel
Save