b3d64986be797cc7f4e48ee7d6f1004e3005031b
braney
Tue May 20 16:24:22 2014 -0700
fix a couple problems found in code review, add some comments, andrearrange the code a little
diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c
index 4e28b57..2b54555 100644
--- src/hg/hgHubConnect/hgHubConnect.c
+++ src/hg/hgHubConnect/hgHubConnect.c
@@ -226,35 +226,31 @@
else
{
// give people a chance to clear the error
ourCellStart();
printf(
" \n"
, hub->hubUrl);
ourCellEnd();
}
if (hub->trackHub != NULL)
{
if (hub->trackHub->descriptionUrl != NULL)
- {
- printf("\n", hub->trackHub->descriptionUrl);
- ourPrintCell(hub->trackHub->shortLabel);
- puts(" ");
- }
+ ourPrintCellLink(hub->trackHub->shortLabel, hub->trackHub->descriptionUrl);
else
ourPrintCell(hub->trackHub->shortLabel);
}
else
ourPrintCell("");
if (!isEmpty(hub->errorMessage))
printf("
ERROR: %s "
"Debug \n",
hub->errorMessage);
else if (hub->trackHub != NULL)
ourPrintCell(hub->trackHub->longLabel);
else
ourPrintCell("");
@@ -310,69 +306,70 @@
return urlSearchHash;
}
static struct hash *outputPublicTable(struct sqlConnection *conn, char *publicTable, char *statusTable)
/* Put up the list of public hubs and other controls for the page. */
{
char *trixFile = cfgOptionEnvDefault("HUBSEARCHTRIXFILE", "hubSearchTrixFile", "/gbdb/hubs/public.ix");
char *hubSearchTerms = cartOptionalString(cart, hgHubSearchTerms);
boolean haveTrixFile = fileExists(trixFile);
struct hash *urlSearchHash = NULL;
if (haveTrixFile && !isEmpty(hubSearchTerms))
urlSearchHash = getUrlSearchHash(trixFile, hubSearchTerms);
-addPublicHubsToHubStatus(conn, publicTable, statusTable);
-
-struct hash *publicHash = NULL;
-char query[512];
-bool hasDescription = sqlColumnExists(conn, publicTable, "descriptionUrl");
-
-if (hasDescription)
- sqlSafef(query, sizeof(query), "select p.hubUrl,p.shortLabel,p.longLabel,p.dbList,s.errorMessage,s.id,p.descriptionUrl from %s p,%s s where p.hubUrl = s.hubUrl",
- publicTable, statusTable);
-else
- sqlSafef(query, sizeof(query), "select p.hubUrl,p.shortLabel,p.longLabel,p.dbList,s.errorMessage,s.id from %s p,%s s where p.hubUrl = s.hubUrl",
- publicTable, statusTable);
-
-struct sqlResult *sr = sqlGetResult(conn, query);
-char **row;
-int count = 0;
-
+// if we have search terms, put out the line telling the user so
if (!isEmpty(hubSearchTerms))
{
printf(" List restricted by search terms : %s\n", hubSearchTerms);
puts(" \n");
printf(" \n");
}
+// if we have a trix file, draw the search box
if (haveTrixFile)
{
puts(" \n"
" \n");
}
+// make sure all the public hubs are in the hubStatus table.
+addPublicHubsToHubStatus(conn, publicTable, statusTable);
+
+struct hash *publicHash = NULL;
+char query[512];
+bool hasDescription = sqlColumnExists(conn, publicTable, "descriptionUrl");
+if (hasDescription)
+ sqlSafef(query, sizeof(query), "select p.hubUrl,p.shortLabel,p.longLabel,p.dbList,s.errorMessage,s.id,p.descriptionUrl from %s p,%s s where p.hubUrl = s.hubUrl",
+ publicTable, statusTable);
+else
+ sqlSafef(query, sizeof(query), "select p.hubUrl,p.shortLabel,p.longLabel,p.dbList,s.errorMessage,s.id from %s p,%s s where p.hubUrl = s.hubUrl",
+ publicTable, statusTable);
+
+struct sqlResult *sr = sqlGetResult(conn, query);
+char **row;
+int count = 0;
boolean gotAnyRows = FALSE;
while ((row = sqlNextRow(sr)) != NULL)
{
++count;
char *url = row[0], *shortLabel = row[1], *longLabel = row[2],
*dbList = row[3], *errorMessage = row[4], *descriptionUrl = row[6];
int id = atoi(row[5]);
if ((urlSearchHash != NULL) && (hashLookup(urlSearchHash, url) == NULL))
continue;
if (gotAnyRows)
webPrintLinkTableNewRow();
else
{
@@ -408,35 +405,31 @@
{
// give user a chance to clear the error
ourCellStart();
printf(
" "
, url);
ourCellEnd();
}
else
errAbort("cannot get id for hub with url %s\n", url);
if (hasDescription && !isEmpty(descriptionUrl))
- {
- printf("\n", descriptionUrl);
ourPrintCellLink(shortLabel, descriptionUrl);
- puts(" ");
- }
else
ourPrintCell(shortLabel);
if (isEmpty(errorMessage))
ourPrintCell(longLabel);
else
printf("ERROR: %s "
"Debug ",
errorMessage);
printGenomeList(slNameListFromComma(dbList), count); // Leaking a bit of memory
ourPrintCell(url);
hashStore(publicHash, url);
}
sqlFreeResult(&sr);