025552d441bacf5bad36164260240d79d51bdac5 galt Tue Oct 15 17:06:08 2019 -0700 fixes #23228. Added a reset button. I also fixed the limit to work right by passing the limit to the SQL query which was oddly not done -- it had only been limiting the drawing of results rather than the fetching of results. It now runs nice and fast. diff --git src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c index 4f89154..2dc134c 100644 --- src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c +++ src/hg/cirm/cdw/cdwWebBrowse/cdwWebBrowse.c @@ -1504,30 +1504,35 @@ fieldedTableAdd(table, row, fieldCount, ++i); } char returnUrl[PATH_LEN*2]; safef(returnUrl, sizeof(returnUrl), "../cgi-bin/cdwWebBrowse?cdwCommand=browseLabs&%s", cartSidUrlString(cart) ); struct hash *outputWrappers = hashNew(0); hashAdd(outputWrappers, "web page", wrapExternalUrl); webSortableFieldedTable(cart, table, returnUrl, "cdwLab", 0, outputWrappers, NULL); fieldedTableFree(&table); } void doAnalysisQuery(struct sqlConnection *conn) /* Print up query page */ { +if (cartNonemptyString(cart, "cdwQueryReset")) + { + cartRemovePrefix(cart, "cdwQuery"); + } + /* Do stuff that keeps us here after a routine submit */ printf("Enter a SQL-like query below. "); printf("In the box after 'select' you can put in a list of tag names including wildcards. "); printf("In the box after 'where' you can put in filters
based on boolean operations between "); printf("fields and constants. Select one of the four formats and press view to see the matching data on "); printf("this page.
The limit can be set lower to increase the query speed.

"); printf("
\n"); cartSaveSession(cart); cgiMakeHiddenVar("cdwCommand", "analysisQuery"); /* Get values from text inputs and make up an RQL query string out of fields, where, limit * clauses */ /* Fields clause */ char *fieldsVar = "cdwQueryFields"; char *fields = cartUsualString(cart, fieldsVar, "*"); @@ -1551,31 +1556,32 @@ printf("from files "); printf("where "); cgiMakeTextVar(whereVar, where, 40); printf(" limit "); cgiMakeIntVar(limitVar, limit, 7); char *menu[3]; menu[0] = "ra"; menu[1] = "tsv"; menu[2] = "csv"; char *formatVar = "cdwQueryFormat"; char *format = cartUsualString(cart, formatVar, menu[0]); printf(" "); cgiMakeDropList(formatVar, menu, ArraySize(menu), format); printf(" "); -printf("\n"); +printf("\n"); +printf("\n"); printf("
\n\n"); printf("
Clicking the download button will take you to a new page with all of the matching data in "); printf("the selected format.
"); printf("
\n"); cartSaveSession(cart); cgiMakeHiddenVar("cdwCommand", "analysisQuery"); cgiMakeHiddenVar("Download format", format); printf("\n", format, format); printf("
\n\n"); // Get field list for the cdwFileTags table, leaving out things we don't want to display on the site // (allAccess and groupIds). struct dyString *descQuery = dyStringNew(0); @@ -1635,30 +1641,32 @@ sqlDyStringPrintfFrag(sqlQuery, "(allAccess = 1"); if (user != NULL) { // Handle group-based access for this user struct dyString *groupQuery = dyStringNew(0); sqlDyStringPrintf(groupQuery, "select groupId from cdwGroupUser where userId = %u\n", user->id); sr = sqlGetResult(conn, groupQuery->string); while ((row = sqlNextRow(sr)) != NULL) { sqlDyStringPrintfFrag(sqlQuery, " or find_in_set(\"%s\", groupIds) > 0", row[0]); } sqlFreeResult(&sr); } sqlDyStringPrintfFrag(sqlQuery, ")"); } +// limit +sqlDyStringPrintfFrag(sqlQuery, " limit %d", limit); // Now to actually fetch the data! sr = sqlGetResult(conn, sqlQuery->string); struct slName *fieldNames = sqlResultFieldList(sr); struct slRef *resultData = NULL; while ((row = sqlNextRow(sr)) != NULL) { struct slPair *fieldList = NULL; struct slName *fieldName = fieldNames; int fieldIdx = 0; while (fieldName != NULL) { char *val = NULL; if (!isEmpty(row[fieldIdx])) val = cloneString(row[fieldIdx]);