83f865717d8dc6ddf020efca430c0a673c094370
braney
  Mon Apr 21 20:07:55 2014 -0700
grab the id's for the hubPublic table from the hubStatus table withoutchecking the remote location unless we haven't seen the hub before.

diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c
index 82239f1..e45fd8f 100644
--- src/hg/hgHubConnect/hgHubConnect.c
+++ src/hg/hgHubConnect/hgHubConnect.c
@@ -244,75 +244,90 @@
 
     ourCellStart();
     printf(
     "<input name=\"hubDisconnectButton\""
 	"onClick=\"document.disconnectHubForm.elements['hubId'].value='%d';"
 	    "document.disconnectHubForm.submit();return true;\" "
 	    "class=\"hubField\" type=\"button\" value=\"X\">\n"
 	    , hub->id);
     ourCellEnd();
     }
 
 printf("</TR></tbody></TABLE>\n");
 printf("</div>");
 }
 
-static struct hash *outputPublicTable(struct sqlConnection *conn, char *publicTable)
+static void addPublicHubsToHubStatus(struct sqlConnection *conn, char *publicTable, char  *statusTable)
+/* add url's in the hubPublic table to the hubStatus table if they aren't there already */
+{
+char query[1024];
+sqlSafef(query, sizeof(query), "select hubUrl from %s where hubUrl not in (select hubUrl from %s)\n", publicTable, statusTable); 
+struct sqlResult *sr = sqlGetResult(conn, query);
+char **row;
+while ((row = sqlNextRow(sr)) != NULL)
+    {
+    char *errorMessage = NULL;
+    char *url = row[0];
+
+    // add this url to the hubStatus table
+    hubFindOrAddUrlInStatusTable(database, cart, url, &errorMessage);
+    }
+}
+
+static struct hash *outputPublicTable(struct sqlConnection *conn, char *publicTable, char *statusTable)
 /* Put up the list of public hubs and other controls for the page. */
 {
+addPublicHubsToHubStatus(conn, publicTable, statusTable);
+
 struct hash *publicHash = NULL;
 char query[512];
-sqlSafef(query, sizeof(query), "select hubUrl,shortLabel,longLabel,dbList from %s", 
-	publicTable); 
+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];
+    	  *dbList = row[3], *errorMessage = row[4];
+    int id = atoi(row[5]);
     if (gotAnyRows)
 	webPrintLinkTableNewRow();
     else
 	{
 	/* output header */
 	printf("<div id=\"publicHubs\" class=\"hubList\"> \n");
 	printf("<table id=\"publicHubsTable\"> "
 	    "<thead><tr> "
 		"<th>Display</th> "
 		"<th>Hub Name</th> "
 		"<th>Description</th> "
 		"<th>Assemblies</th> "
 		"<th>URL</th> "
 	    "</tr></thead>\n");
 
 	// start first row
 	printf("<tbody> <tr>");
 	gotAnyRows = TRUE;
 
 	// allocate the hash to store hubUrl's
 	publicHash = newHash(5);
 	}
 
-    char *errorMessage = NULL;
-    // get an id for this hub
-    unsigned id = hubFindOrAddUrlInStatusTable(database, cart, 
-	url, &errorMessage);
-
     if ((id != 0) && isEmpty(errorMessage)) 
 	{
 	ourCellStart();
 	char hubName[32];
 	safef(hubName, sizeof(hubName), "%s%u", hgHubConnectHubVarPrefix, id);
 	cartMakeCheckBox(cart, hubName, FALSE);
 	ourCellEnd();
 	}
     else if (!isEmpty(errorMessage))
 	{
 	// give user a chance to clear the error
 	ourCellStart();
 	printf(
 	"<input name=\"hubClearButton\""
 	    "onClick=\"document.resetHubForm.elements['hubUrl'].value='%s';"
@@ -343,32 +358,34 @@
     {
     printf("</TR></tbody></TABLE>\n");
     printf("</div>");
     }
 return publicHash;
 }
 
 
 struct hash *hgHubConnectPublic()
 /* Put up the list of public hubs and other controls for the page. */
 {
 struct hash *retHash = NULL;
 struct sqlConnection *conn = hConnectCentral();
 char *publicTable = cfgOptionEnvDefault("HGDB_HUB_PUBLIC_TABLE", 
 	hubPublicTableConfVariable, defaultHubPublicTableName);
+char *statusTable = cfgOptionEnvDefault("HGDB_HUB_STATUS_TABLE", 
+	hubStatusTableConfVariable, defaultHubStatusTableName);
 if (!(sqlTableExists(conn, publicTable) && 
-	(retHash = outputPublicTable(conn, publicTable)) != NULL ))
+	(retHash = outputPublicTable(conn, publicTable,statusTable)) != NULL ))
     {
     printf("<div id=\"publicHubs\" class=\"hubList\"> \n");
     printf("No Public Track Hubs for this genome assembly<BR>");
     printf("</div>");
     }
 hDisconnectCentral(&conn);
 
 return retHash;
 }
 
 static void tryHubOpen(unsigned id)
 /* try to open hub, leaks trackHub structure */
 {
 /* try opening this again to reset error */
 struct sqlConnection *conn = hConnectCentral();