From a79ed847ab8051e26cc301ae5e6a899c103d6336 Mon Sep 17 00:00:00 2001 From: onefang Date: Wed, 18 Aug 2021 15:47:59 +1000 Subject: sledjchisl status function for members. --- src/sledjchisl/sledjchisl.c | 90 ++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 3821a7b..aae3031 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c @@ -2004,7 +2004,7 @@ byTab has the short name as the key, simData as the value. // TODO - report CPU and memory used as well. if (FLAG(m)) { -// TODO - report level, online status, and location of member. + ; // Do nothing, this is better done in the calling function, coz it has the details. } else if (checkSimIsRunning(simd->tab)) I("%s is running in Tmux tab [%d:%s](pane %d) tmux ID %s, from %s/sim%d", simd->name, window, type, pane, simd->paneID, scTemp, count); @@ -7446,60 +7446,76 @@ void account_html(char *file, reqData *Rd, HTMLfile *thisFile) void forEachMember(char *verb, simFunction func, simFunction not) { - if (NULL != ourSims->target) - func(NULL, ourSims->target, "Member", 0, 0, 0, 0); - else + char *last = xstrdup("0"); + + if (BACKUP == currentMode) { char *file = xmprintf("%s/.lastTime", scBackup); - char *last = (char *) qfile_load(file, NULL); char *cmd = xmprintf("date +%%s > %s", file); + last = (char *) qfile_load(file, NULL); if (NULL == last) last = xstrdup("0"); if (!WIFEXITED(system(cmd))) E("date command failed!"); + free(cmd); + free(file); + } - static dbRequest *users = NULL; - if (NULL == users) - { - static char *szi[] = {NULL}; - static char *szo[] = {"FirstName", "LastName", NULL}; - users = xzalloc(sizeof(dbRequest)); - users->table = "UserAccounts,GridUser"; - users->inParams = szi; - users->outParams = szo; - users->where = xmprintf("UserAccounts.PrincipalID=LEFT(GridUser.UserID,36) and GridUser.Login>%s order by LastName,FirstName", last); - dbRequests->addfirst(dbRequests, &users, sizeof(dbRequest *)); - } + static dbRequest *users = NULL; + if (NULL == users) + { + static char *szi[] = {NULL}; + static char *szo[] = {"FirstName", "LastName", "UserLevel", "Online", "LastRegionID", NULL}; + users = xzalloc(sizeof(dbRequest)); + users->table = "UserAccounts,GridUser"; + users->inParams = szi; + users->outParams = szo; + users->where = xmprintf("UserAccounts.PrincipalID=LEFT(GridUser.UserID,36) and GridUser.Login>%s order by LastName,FirstName", last); + dbRequests->addfirst(dbRequests, &users, sizeof(dbRequest *)); + } - dbDoSomething(users, FALSE); // LEAKY - rowData *rows = users->rows; - if (rows) - { - qhashtbl_t *row; + dbDoSomething(users, FALSE); + rowData *rows = users->rows; + if (rows) + { + qhashtbl_t *row; d("Number of rows returned %d", (int) rows->rows->size(rows->rows)); - while (NULL != (row = rows->rows->getat(rows->rows, 0, NULL, true))) + while (NULL != (row = rows->rows->getat(rows->rows, 0, NULL, true))) + { + char *firstName = row->getstr(row, "FirstName", false); + char *lastName = row->getstr(row, "LastName", false); + char *name = xmprintf("%s %s", firstName, lastName); + + if ((NULL == ourSims->target) || (strcmp(ourSims->target, name) == 0)) { - char *firstName = row->getstr(row, "FirstName", false); - char *lastName = row->getstr(row, "LastName", false); - char *name = xmprintf("%s %s", firstName, lastName); + if (STATUS == currentMode) + { + char *level = row->getstr(row, "UserLevel", false); + char *online = row->getstr(row, "Online", false); + char *region = row->getstr(row, "LastRegionID", false); + simData *simd = ourSims->byUUID->get(ourSims->byUUID, region, NULL, false); -V("Member %s %s", firstName, lastName); - func(NULL, name, "Member", 0, 0, 0, 0); + if (NULL != simd) + region = simd->name; + if (strcmp("False", online) == 0) + region = ""; - free(name); - row->free(row); - rows->rows->removefirst(rows->rows); + I("Member level %s, online %s, name %s %s @ %s", level, online, firstName, lastName, region); + } + func(NULL, name, "Member", 0, 0, 0, 0); } - free(rows->fieldNames); - rows->rows->free(rows->rows); - free(rows); + + free(name); + row->free(row); + rows->rows->removefirst(rows->rows); } - free(cmd); - free(last); - free(file); + free(rows->fieldNames); + rows->rows->free(rows->rows); + free(rows); } + free(last); } -- cgit v1.1