c691103685d313c146aded7c45852ac7678267d1 hiram Fri Aug 2 14:31:19 2019 -0700 do not show itemCounts for containers, they have no items to count refs #23589 diff --git src/hg/hubApi/list.c src/hg/hubApi/list.c index 78775a7..f3e51cb 100644 --- src/hg/hubApi/list.c +++ src/hg/hubApi/list.c @@ -288,36 +288,39 @@ } errCatchEnd(errCatch); if (isNotEmpty(errCatch->message->string)) fprintf(stderr, "%s", errCatch->message->string); errCatchFree(&errCatch); return itemCount; } static void outputTrackDbVars(struct jsonWrite *jw, struct trackDb *tdb, long long itemCount) /* JSON output the fundamental trackDb variables */ { if (NULL == tdb) /* might not be any trackDb */ return; +boolean isContainer = tdbIsComposite(tdb) || tdbIsCompositeView(tdb); + boolean protectedData = FALSE; if (trackDbSetting(tdb, "tableBrowser")) protectedData = TRUE; jsonWriteString(jw, "shortLabel", tdb->shortLabel); jsonWriteString(jw, "type", tdb->type); jsonWriteString(jw, "longLabel", tdb->longLabel); +if (! isContainer) /* containers do not have items to count */ jsonWriteNumber(jw, "itemCount", itemCount); if (tdb->parent) { jsonWriteString(jw, "parent", tdb->parent->track); if (tdb->parent->parent) jsonWriteString(jw, "parentParent", tdb->parent->parent->track); } if (tdb->settingsHash) { struct hashEl *hel; struct hashCookie hc = hashFirst(tdb->settingsHash); while ((hel = hashNext(&hc)) != NULL) { if (sameWord("track", hel->name)) continue; // already output in header @@ -627,46 +630,46 @@ { itemCount = 0; } else { char query[2048]; sqlSafef(query, sizeof(query), "select count(*) from %s", tableName); itemCount = sqlQuickNum(conn, query); } } hFreeConn(&conn); } } } return itemCount; -} +} /* static long long dataItemCount(char *db, struct trackDb *tdb) */ static void recursiveTrackList(struct jsonWrite *jw, struct trackDb *tdb, char *db) /* output trackDb tags only for real tracks, not containers, * recursive when subtracks exist */ { boolean isContainer = tdbIsComposite(tdb) || tdbIsCompositeView(tdb); /* do *NOT* print containers when 'trackLeavesOnly' requested */ if (! (trackLeavesOnly && isContainer) ) { long long itemCount = 0; - /* do not show counts for protected data */ - if (! trackDbSetting(tdb, "tableBrowser")) + /* do not show counts for protected data or continers (== no items)*/ + if (! (isContainer || trackDbSetting(tdb, "tableBrowser"))) itemCount = dataItemCount(db, tdb); jsonWriteObjectStart(jw, tdb->track); if (tdbIsComposite(tdb)) jsonWriteString(jw, "compositeContainer", "TRUE"); if (tdbIsCompositeView(tdb)) jsonWriteString(jw, "compositeViewContainer", "TRUE"); outputTrackDbVars(jw, tdb, itemCount); if (tdb->subtracks) { struct trackDb *el = NULL; for (el = tdb->subtracks; el != NULL; el = el->next ) recursiveTrackList(jw, el, db); }