Browse Source

ckdb - marks action=pps to recalc the ram pps values for a shift

master
kanoi 9 years ago
parent
commit
b7944bd27a
  1. 2
      src/ckdb.h
  2. 35
      src/ckdb_cmd.c

2
src/ckdb.h

@ -55,7 +55,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "1.0.4" #define DB_VERSION "1.0.4"
#define CKDB_VERSION DB_VERSION"-1.610" #define CKDB_VERSION DB_VERSION"-1.611"
#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__

35
src/ckdb_cmd.c

@ -5796,7 +5796,7 @@ static char *cmd_marks(PGconn *conn, char *cmd, char *id,
char description[TXT_BIG+1] = { '\0' }; char description[TXT_BIG+1] = { '\0' };
char extra[TXT_BIG+1] = { '\0' }; char extra[TXT_BIG+1] = { '\0' };
char status[TXT_FLAG+1] = { MARK_READY, '\0' }; char status[TXT_FLAG+1] = { MARK_READY, '\0' };
bool ok; bool ok = false, pps;
LOGDEBUG("%s(): cmd '%s'", __func__, cmd); LOGDEBUG("%s(): cmd '%s'", __func__, cmd);
@ -6237,6 +6237,39 @@ static char *cmd_marks(PGconn *conn, char *cmd, char *id,
old ? "On" : "Off", old ? "On" : "Off",
markersummary_auto ? "On" : "Off"); markersummary_auto ? "On" : "Off");
ok = true; ok = true;
} else if (strcasecmp(action, "pps") == 0) {
/* Recalculate a shift's rewards/rewarded
* Require markerid */
i_markerid = require_name(trf_root, "markerid", 1,
(char *)intpatt, reply, siz);
if (!i_markerid)
return strdup(reply);
TXT_TO_BIGINT("markerid", transfer_data(i_markerid), markerid);
K_RLOCK(workmarkers_free);
wm_item = find_workmarkerid(markerid, false, MARKER_PROCESSED);
K_RUNLOCK(workmarkers_free);
if (!wm_item) {
snprintf(reply, siz, "no markerid %"PRId64, markerid);
return strdup(reply);
}
DATA_WORKMARKERS(workmarkers, wm_item);
pps = shift_rewards(wm_item);
if (pps) {
snprintf(msg, sizeof(msg),
"shift '%s' markerid %"PRId64" rewards %d "
"rewarded %.3e pps %.3e",
workmarkers->description,
workmarkers->markerid, workmarkers->rewards,
workmarkers->rewarded, workmarkers->pps_value);
} else {
snprintf(msg, sizeof(msg),
"shift '%s' markerid %"PRId64" no rewards yet"
" pps %.3e",
workmarkers->description,
workmarkers->markerid, workmarkers->pps_value);
}
ok = true;
} else { } else {
snprintf(reply, siz, "unknown action '%s'", action); snprintf(reply, siz, "unknown action '%s'", action);
LOGERR("%s.%s", id, reply); LOGERR("%s.%s", id, reply);

Loading…
Cancel
Save