2776159fd4f68c3c5a1a114f238dc2f568a5bd64 hiram Fri Sep 27 11:07:16 2024 -0700 allow use of new genark table with more columns refs #32596 diff --git src/hg/hgGateway/hgGateway.c src/hg/hgGateway/hgGateway.c index 00f18be..f262d8e 100644 --- src/hg/hgGateway/hgGateway.c +++ src/hg/hgGateway/hgGateway.c @@ -18,30 +18,31 @@ #include "hCommon.h" #include "hgConfig.h" #include "hdb.h" #include "htmshell.h" #include "hubConnect.h" #include "hui.h" #include "jsHelper.h" #include "jsonParse.h" #include "obscure.h" // for readInGulp #include "regexHelper.h" #include "suggest.h" #include "trackHub.h" #include "web.h" #include "botDelay.h" #include "genark.h" +#include "assemblyList.h" /* Global Variables */ struct cart *cart = NULL; /* CGI and other variables */ struct hash *oldVars = NULL; /* Old contents of cart before it was updated by CGI */ static boolean issueBotWarning = FALSE; static int measureTiming = 0; static long enteredMainTime = 0; #define SEARCH_TERM "hggw_term" static char *maybeGetDescriptionText(char *db) /* Slurp the description.html file for db into a string (if possible, don't die if * we can't read it) and return it. */ { @@ -966,37 +967,47 @@ } if (ret) slReverse(&ret); return ret; } static struct gHubMatch *searchGenark(char *term) /* Search through the genark table for hubs matches term */ { char *genarkPrefix = cfgOption("genarkHubPrefix"); if (genarkPrefix == NULL) return NULL; struct gHubMatch *gHubMatchList = NULL; char *genarkTbl = genarkTableName(); +int colCount = genArkColumnCount(); struct sqlConnection *conn = hConnectCentral(); if (sqlTableExists(conn, genarkTbl)) { char query[1024]; + if (colCount > 6) + { + sqlSafef(query, sizeof(query), "select * from %s where " + "(gcAccession like '%%%s%%' or scientificName like '%%%s%%' or commonName like '%%%s%%' or asmName like '%%%s%%') order by priority", + genarkTbl, term, term, term, term); + } + else + { sqlSafef(query, sizeof(query), "select * from %s where " "(gcAccession like '%%%s%%' or scientificName like '%%%s%%' or commonName like '%%%s%%' or asmName like '%%%s%%') order by taxId ASC, commonName DESC", genarkTbl, term, term, term, term); + } struct genark *matchList = genarkLoadByQuery(conn, query); gHubMatchList = filterGenarkMatches(genarkPrefix, matchList); } hDisconnectCentral(&conn); return gHubMatchList; } static char *getSearchTermUpperCase() /* If we don't have the SEARCH_TERM cgi param, exit with an HTTP Bad Request response. * If we do, convert it to upper case for case-insensitive matching and return it. */ { pushWarnHandler(htmlVaBadRequestAbort); pushAbortHandler(htmlVaBadRequestAbort); char *cgiTerm = cgiOptionalString(SEARCH_TERM); char *term = skipLeadingSpaces(cgiTerm);