|
|
@ -7755,17 +7755,86 @@ bool markersummary_fill(PGconn *conn) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ExecStatusType rescode; |
|
|
|
ExecStatusType rescode; |
|
|
|
PGresult *res; |
|
|
|
PGresult *res; |
|
|
|
K_ITEM *item = NULL, *p_item; |
|
|
|
K_ITEM *item = NULL, *p_item, *wm_item = NULL; |
|
|
|
|
|
|
|
K_TREE_CTX ctx[1]; |
|
|
|
|
|
|
|
char cd_buf[DATE_BUFSIZ]; |
|
|
|
|
|
|
|
char *cd = NULL, *what = NULL; |
|
|
|
int n, t, i, p_n; |
|
|
|
int n, t, i, p_n; |
|
|
|
MARKERSUMMARY *row, *p_row; |
|
|
|
MARKERSUMMARY *row, *p_row; |
|
|
|
|
|
|
|
WORKMARKERS *workmarkers; |
|
|
|
char *params[1]; |
|
|
|
char *params[1]; |
|
|
|
char *field; |
|
|
|
char *field; |
|
|
|
char *sel; |
|
|
|
char *sel; |
|
|
|
int fields = 20, par = 0; |
|
|
|
int fields = 20, par = 0; |
|
|
|
|
|
|
|
int64_t ms = 0, amt = 0; |
|
|
|
bool ok = false; |
|
|
|
bool ok = false; |
|
|
|
|
|
|
|
tv_t old; |
|
|
|
|
|
|
|
|
|
|
|
LOGDEBUG("%s(): select", __func__); |
|
|
|
LOGDEBUG("%s(): select", __func__); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mark_start < 0) |
|
|
|
|
|
|
|
mark_start = 0; |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
amt = ms = mark_start; |
|
|
|
|
|
|
|
switch (mark_start_type) { |
|
|
|
|
|
|
|
case 'D': // mark_start days
|
|
|
|
|
|
|
|
setnow(&old); |
|
|
|
|
|
|
|
old.tv_sec -= 60 * 60 * 24 * ms; |
|
|
|
|
|
|
|
K_RLOCK(workmarkers_free); |
|
|
|
|
|
|
|
wm_item = last_in_ktree(workmarkers_root, ctx); |
|
|
|
|
|
|
|
while (wm_item) { |
|
|
|
|
|
|
|
// Newest processed workmarker <= old
|
|
|
|
|
|
|
|
DATA_WORKMARKERS(workmarkers, wm_item); |
|
|
|
|
|
|
|
if (CURRENT(&(workmarkers->expirydate)) && |
|
|
|
|
|
|
|
WMPROCESSED(workmarkers->status) && |
|
|
|
|
|
|
|
!tv_newer(&old, &(workmarkers->createdate))) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
wm_item = prev_in_ktree(ctx); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!wm_item) |
|
|
|
|
|
|
|
mark_start = 0; |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
mark_start = workmarkers->markerid; |
|
|
|
|
|
|
|
tv_to_buf(&(workmarkers->createdate), |
|
|
|
|
|
|
|
cd_buf, sizeof(cd_buf)); |
|
|
|
|
|
|
|
cd = cd_buf; |
|
|
|
|
|
|
|
what = "days"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
K_RUNLOCK(workmarkers_free); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'S': // mark_start shifts (workmarkers)
|
|
|
|
|
|
|
|
K_RLOCK(workmarkers_free); |
|
|
|
|
|
|
|
wm_item = last_in_ktree(workmarkers_root, ctx); |
|
|
|
|
|
|
|
while (wm_item) { |
|
|
|
|
|
|
|
DATA_WORKMARKERS(workmarkers, wm_item); |
|
|
|
|
|
|
|
if (CURRENT(&(workmarkers->expirydate)) && |
|
|
|
|
|
|
|
WMPROCESSED(workmarkers->status)) { |
|
|
|
|
|
|
|
ms--; |
|
|
|
|
|
|
|
if (ms <= 0) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
wm_item = prev_in_ktree(ctx); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!wm_item) |
|
|
|
|
|
|
|
mark_start = 0; |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
mark_start = workmarkers->markerid; |
|
|
|
|
|
|
|
tv_to_buf(&(workmarkers->createdate), |
|
|
|
|
|
|
|
cd_buf, sizeof(cd_buf)); |
|
|
|
|
|
|
|
cd = cd_buf; |
|
|
|
|
|
|
|
what = "shifts"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
K_RUNLOCK(workmarkers_free); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'M': // markerid = mark_start
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
/* Not possible unless ckdb.c is different
|
|
|
|
|
|
|
|
* in which case it will just use mark_start */ |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// TODO: limit how far back
|
|
|
|
// TODO: limit how far back
|
|
|
|
sel = "declare ws cursor for select " |
|
|
|
sel = "declare ws cursor for select " |
|
|
|
"markerid,userid,workername,diffacc,diffsta,diffdup,diffhi," |
|
|
|
"markerid,userid,workername,diffacc,diffsta,diffdup,diffhi," |
|
|
@ -7774,14 +7843,16 @@ bool markersummary_fill(PGconn *conn) |
|
|
|
"lastshareacc,lastdiffacc" |
|
|
|
"lastshareacc,lastdiffacc" |
|
|
|
MODIFYDATECONTROL |
|
|
|
MODIFYDATECONTROL |
|
|
|
" from markersummary where markerid>=$1"; |
|
|
|
" from markersummary where markerid>=$1"; |
|
|
|
|
|
|
|
|
|
|
|
par = 0; |
|
|
|
par = 0; |
|
|
|
if (mark_start) |
|
|
|
params[par++] = bigint_to_buf(mark_start, NULL, 0); |
|
|
|
params[par++] = mark_start; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
params[par++] = "0"; |
|
|
|
|
|
|
|
PARCHK(par, params); |
|
|
|
PARCHK(par, params); |
|
|
|
|
|
|
|
|
|
|
|
LOGWARNING("%s(): loading from markerid>=%s", __func__, params[0]); |
|
|
|
LOGWARNING("%s(): loading from markerid>=%s", __func__, params[0]); |
|
|
|
|
|
|
|
if (cd) { |
|
|
|
|
|
|
|
LOGWARNING(" ... %s = %s >= %"PRId64" %s", |
|
|
|
|
|
|
|
params[0], cd, amt, what); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
printf(TICK_PREFIX"ms 0\r"); |
|
|
|
printf(TICK_PREFIX"ms 0\r"); |
|
|
|
fflush(stdout); |
|
|
|
fflush(stdout); |
|
|
@ -8016,6 +8087,10 @@ flail: |
|
|
|
res = PQexec(conn, "Commit", CKPQ_READ); |
|
|
|
res = PQexec(conn, "Commit", CKPQ_READ); |
|
|
|
PQclear(res); |
|
|
|
PQclear(res); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < par; i++) |
|
|
|
|
|
|
|
free(params[i]); |
|
|
|
|
|
|
|
par = 0; |
|
|
|
|
|
|
|
|
|
|
|
if (ok) { |
|
|
|
if (ok) { |
|
|
|
LOGDEBUG("%s(): built", __func__); |
|
|
|
LOGDEBUG("%s(): built", __func__); |
|
|
|
LOGWARNING("%s(): fetched %d markersummary records", __func__, n); |
|
|
|
LOGWARNING("%s(): fetched %d markersummary records", __func__, n); |
|
|
|