748b06ac95ff2a3957be3845bd3594984e3cc3cf
chmalee
  Wed Aug 17 19:21:48 2022 -0700
Rename test cgi to official name. Always search everything, only show
categories that have matches in the result list. Add /search endpoint to
hubApi, add code to search help docs in hgSuggest but don't call it yet
in autoComplete.js. Minor fixups so search result links work correctly.

Fixing up old programs that call hgPositionsFind

diff --git src/hg/cgilib/cartJson.c src/hg/cgilib/cartJson.c
index 8c0914e..89785df 100644
--- src/hg/cgilib/cartJson.c
+++ src/hg/cgilib/cartJson.c
@@ -68,31 +68,32 @@
 }
 
 void hgPositionsJson(struct jsonWrite *jw, char *db, struct hgPositions *hgp, struct cart *cart)
 /* Write out JSON description of multiple position matches. */
 {
 struct hgPosTable *table;
 jsonWriteListStart(jw, "positionMatches");
 struct trackDb *tdbList = NULL;
 for (table = hgp->tableList; table != NULL; table = table->next)
     {
     if (table->posList != NULL)
         {
         char *trackName = table->name, *tableName = table->name;
         struct trackDb *tdb = NULL;
         // clear the tdb cache if this track is a hub track
-        if (! (sameString("trackDb", tableName) || sameString("helpDocs", tableName) || sameString("publicHubs", tableName)))
+        if (! (sameString("trackDb", tableName) || sameString("helpDocs", tableName) ||
+                sameString("publicHubs", tableName)))
             {
             if (isHubTrack(tableName))
                 tdbList = NULL;
             tdb = tdbForTrack(db, tableName, &tdbList);
             if (!tdb && startsWith("all_", tableName))
                 tdb = tdbForTrack(db, tableName+strlen("all_"), &tdbList);
             if (!tdb)
                 errAbort("no track for table \"%s\" found via a findSpec", tableName);
             trackName = tdb->track;
             }
         jsonWriteObjectStart(jw, NULL);
         jsonWriteString(jw, "name", table->name);
         jsonWriteString(jw, "trackName", trackName);
         jsonWriteString(jw, "description", table->description);
         if (tdb != NULL)
@@ -121,31 +122,31 @@
                     jsonWriteStringf(jw, "extraSel", "%s_sel=1&%s_sel=1&",
                                      trackName, tdb->parent->track);
                     }
                 }
             jsonWriteString(jw, "hgFindMatches", encMatches);
             jsonWriteString(jw, "posName", htmlEncode(pos->name));
             jsonWriteBoolean(jw, "canonical", pos->canonical);
             if (pos->description)
                 {
                 stripString(pos->description, "\n");
                 jsonWriteString(jw, "description", stripAnchor(pos->description));
                 }
             jsonWriteObjectEnd(jw); // end one match
             }
         jsonWriteListEnd(jw); // end matches
-        if (table->searchTime != 0)
+        if (table->searchTime >= 0)
             jsonWriteNumber(jw, "searchTime", table->searchTime);
         jsonWriteObjectEnd(jw); // end one table
 	}
     }
     jsonWriteListEnd(jw); // end positionMatches
 }
 
 static struct hgPositions *genomePosCJ(struct jsonWrite *jw,
 				       char *db, char *spec, char **retChromName,
 				       int *retWinStart, int *retWinEnd, struct cart *cart)
 /* Search for positions in genome that match user query.
  * Return an hgp unless there is a problem.  hgp->singlePos will be set if a single
  * position matched.
  * Otherwise display list of positions, put # of positions in retWinStart,
  * and return NULL. */