e39d2c40cdc3e17273b158602400481ae7d2d03d
hiram
  Wed Aug 28 18:44:07 2024 -0700
correspond with the new table structure and properly output the number values refs #32596

diff --git src/hg/hubApi/findGenome.c src/hg/hubApi/findGenome.c
index d1251b6..b925041 100644
--- src/hg/hubApi/findGenome.c
+++ src/hg/hubApi/findGenome.c
@@ -41,44 +41,66 @@
 | description    | varchar(1023)       | YES  |     | NULL    |       |
 | browserExists  | tinyint(3) unsigned | YES  |     | NULL    |       |
 | hubUrl         | varchar(511)        | YES  |     | NULL    |       |
 +----------------+---------------------+------+-----+---------+-------+
 */
 
 static long long sqlJsonOut(struct jsonWrite *jw, struct sqlResult *sr)
 /* given a sqlResult, walk through the rows and output the json */
 {
 long long itemCount = 0;
 char **row;
 while ((row = sqlNextRow(sr)) != NULL)
     {
     struct assemblyList *el = assemblyListLoadWithNull(row);
     jsonWriteObjectStart(jw, el->name);
-    jsonWriteNumber(jw, "priority", (long long)el->priority);
+    if (el->priority)
+        jsonWriteNumber(jw, "priority", (long long)*el->priority);
+    else
+        jsonWriteNumber(jw, "priority", (long long)0);
     jsonWriteString(jw, "commonName", el->commonName);
     jsonWriteString(jw, "scientificName", el->scientificName);
-    jsonWriteNumber(jw, "taxId", (long long)el->taxId);
+    if (el->taxId)
+        jsonWriteNumber(jw, "taxId", (long long)*el->taxId);
+    else
+        jsonWriteNumber(jw, "taxId", (long long)0);
     jsonWriteString(jw, "clade", el->clade);
     jsonWriteString(jw, "description", el->description);
     if (1 == *el->browserExists)
         jsonWriteBoolean(jw, "browserExists", TRUE);
     else
         jsonWriteBoolean(jw, "browserExists", FALSE);
     if (isEmpty(el->hubUrl))
         jsonWriteString(jw, "hubUrl", NULL);
     else
         jsonWriteString(jw, "hubUrl", el->hubUrl);
+    if (el->year)
+        jsonWriteNumber(jw, "year", (long long)*el->year);
+    else
+        jsonWriteNumber(jw, "year", (long long)0);
+    if (isEmpty(el->refSeqCategory))
+        jsonWriteString(jw, "refSeqCategory", NULL);
+    else
+        jsonWriteString(jw, "refSeqCategory", el->refSeqCategory);
+    if (isEmpty(el->versionStatus))
+        jsonWriteString(jw, "versionStatus", NULL);
+    else
+        jsonWriteString(jw, "versionStatus", el->versionStatus);
+    if (isEmpty(el->assemblyLevel))
+        jsonWriteString(jw, "assemblyLevel", NULL);
+    else
+        jsonWriteString(jw, "assemblyLevel", el->assemblyLevel);
     jsonWriteObjectEnd(jw);
     ++itemCount;
     }
 return (itemCount);
 }
 
 static long long multipleWordSearch(struct sqlConnection *conn, char **words, int wordCount, struct jsonWrite *jw, long long *totalMatchCount)
 /* perform search on multiple words, prepare json and return number of matches */
 {
 long long itemCount = 0;
 *totalMatchCount = 0;
 if (wordCount < 0)
     return itemCount;
 
 /* get the words[] into a single string */
@@ -95,91 +117,91 @@
     sqlDyStringPrintf(query, " AND browserExists=1");
 else if (browserNotExist)
     sqlDyStringPrintf(query, " AND browserExists=0");
 long long matchCount = sqlQuickLongLong(conn, query->string);
 if (matchCount > 0)
     {
     *totalMatchCount = matchCount;
     if (statsOnly)	// only counting, nothing returned
 	{	// the LIMIT would limit results to maxItemsOutput
 	itemCount = min(maxItemsOutput, matchCount);
 	}	// when less than totalMatchCount
     else
 	{
 	dyStringFree(&query);
 	query = dyStringNew(64);
-	sqlDyStringPrintf(query, "SELECT * FROM %s WHERE MATCH(name, commonName, scientificName, clade, description) AGAINST ('%s' IN BOOLEAN MODE)", asmListTable, queryDy->string);
+	sqlDyStringPrintf(query, "SELECT * FROM %s WHERE MATCH(name, commonName, scientificName, clade, description, refSeqCategory, versionStatus, assemblyLevel) AGAINST ('%s' IN BOOLEAN MODE)", asmListTable, queryDy->string);
 	/* add specific browserExists depending upon options */
 	if (browserMustExist)
 	    sqlDyStringPrintf(query, " AND browserExists=1");
 	else if (browserNotExist)
 	    sqlDyStringPrintf(query, " AND browserExists=0");
 	sqlDyStringPrintf(query, " ORDER BY priority LIMIT %d;", maxItemsOutput);
 	struct sqlResult *sr = sqlGetResult(conn, query->string);
 	itemCount = sqlJsonOut(jw, sr);
 	sqlFreeResult(&sr);
 	dyStringFree(&query);
 	}
     }
 return itemCount;
 }
 
 static long long oneWordSearch(struct sqlConnection *conn, char *searchWord, struct jsonWrite *jw, long long *totalMatchCount, boolean *prefixSearch)
 /* perform search on a single word, prepare json and return number of matches
  *   and number of potential matches totalMatchCount
  */
 {
 long long itemCount = 0;
 *totalMatchCount = 0;
 
 struct dyString *query = dyStringNew(64);
-sqlDyStringPrintf(query, "SELECT COUNT(*) FROM %s WHERE MATCH(name, commonName, scientificName, clade, description) AGAINST ('%s' IN BOOLEAN MODE)", asmListTable, searchWord);
+sqlDyStringPrintf(query, "SELECT COUNT(*) FROM %s WHERE MATCH(name, commonName, scientificName, clade, description, refSeqCategory, versionStatus, assemblyLevel) AGAINST ('%s' IN BOOLEAN MODE)", asmListTable, searchWord);
 if (browserMustExist)
     sqlDyStringPrintf(query, " AND browserExists=1");
 else if (browserNotExist)
     sqlDyStringPrintf(query, " AND browserExists=0");
 
 long long matchCount = sqlQuickLongLong(conn, query->string);
 *prefixSearch = FALSE;	/* assume not */
 if (matchCount < 1)	/* no match, add the * wild card match to make a prefix match */
     {
     dyStringFree(&query);
     query = dyStringNew(64);
-    sqlDyStringPrintf(query, "SELECT COUNT(*) FROM %s WHERE MATCH(name, commonName, scientificName, clade, description) AGAINST ('%s*' IN BOOLEAN MODE)", asmListTable, searchWord);
+    sqlDyStringPrintf(query, "SELECT COUNT(*) FROM %s WHERE MATCH(name, commonName, scientificName, clade, description, refSeqCategory, versionStatus, assemblyLevel) AGAINST ('%s*' IN BOOLEAN MODE)", asmListTable, searchWord);
     /* add specific browserExists depending upon options */
     if (browserMustExist)
 	sqlDyStringPrintf(query, " AND browserExists=1");
     else if (browserNotExist)
 	sqlDyStringPrintf(query, " AND browserExists=0");
     matchCount = sqlQuickLongLong(conn, query->string);
     if (matchCount > 0)
 	*prefixSearch = TRUE;
     }
 if (matchCount < 1)	// nothing found, returning zero
     return itemCount;
 *totalMatchCount = matchCount;
 
 if (statsOnly)	// only counting, nothing returned
     {	// the LIMIT would limit results to maxItemsOutput
     itemCount = min(maxItemsOutput, matchCount);
     }	// when less than totalMatchCount
 else
     {
     dyStringFree(&query);
     query = dyStringNew(64);
 
-    sqlDyStringPrintf(query, "SELECT * FROM %s WHERE MATCH(name, commonName, scientificName, clade, description) AGAINST ('%s%s' IN BOOLEAN MODE)", asmListTable, searchWord, *prefixSearch ? "*" : "");
+    sqlDyStringPrintf(query, "SELECT * FROM %s WHERE MATCH(name, commonName, scientificName, clade, description, refSeqCategory, versionStatus, assemblyLevel) AGAINST ('%s%s' IN BOOLEAN MODE)", asmListTable, searchWord, *prefixSearch ? "*" : "");
     /* add specific browserExists depending upon options */
     if (browserMustExist)
 	sqlDyStringPrintf(query, " AND browserExists=1");
     else if (browserNotExist)
 	sqlDyStringPrintf(query, " AND browserExists=0");
     sqlDyStringPrintf(query, " ORDER BY priority LIMIT %d;", maxItemsOutput);
     struct sqlResult *sr = sqlGetResult(conn, query->string);
     itemCount = sqlJsonOut(jw, sr);
     sqlFreeResult(&sr);
     dyStringFree(&query);
     }
 
 return itemCount;
 }	/*	static long long oneWordSearch(struct sqlConnection *conn, char *searchWord, struct jsonWrite *jw, boolean *prefixSearch) */