087a13bbad05abc419766da9ef4c4879bb90f294 galt Wed Feb 7 00:46:52 2018 -0800 adjusting the selected facet count algorithm to handle the ignore-null-values option. diff --git src/hg/lib/facetField.c src/hg/lib/facetField.c index 691acb8..95d54c3 100644 --- src/hg/lib/facetField.c +++ src/hg/lib/facetField.c @@ -122,55 +122,64 @@ } } } selectedFields = end+1; } } int selectedRowCount = 0; /* Scan through result saving it in list. */ struct sqlResult *sr = sqlGetResult(conn, query->string); char **row; while ((row = sqlNextRow(sr)) != NULL) { int totalSelectedFacets = 0; + int facetCount = 0; // non-NULL facet count for (i=0; i<fieldCount; ++i) { char *val = row[i]; if (val == NULL) val = nullVal; if (val != NULL) { facetFieldAdd(ffArray[i], val, FALSE); if (ffArray[i]->currentVal->selected) ++totalSelectedFacets; + ++facetCount; + } + else + { + ffArray[i]->currentVal = NULL; } } - if (totalSelectedFacets == fieldCount) + if ((totalSelectedFacets == facetCount) && (facetCount > 0)) { // include this row in the final resultset ++selectedRowCount; } for (i=0; i<fieldCount; ++i) { + if (ffArray[i]->currentVal) // disregard null values + { // disregard one's self. - if ((totalSelectedFacets - (int)ffArray[i]->currentVal->selected) == (fieldCount - 1)) + if ((totalSelectedFacets - (int)ffArray[i]->currentVal->selected) == (facetCount - 1)) ffArray[i]->currentVal->selectCount++; // shown on GUI to guide choosing by user } + } } /* Sort lists */ for (ff = ffList; ff != NULL; ff = ff->next) slSort(&ff->valList, facetValCmpUseCountDesc); /* Clean up and go home */ dyStringFree(&query); sqlFreeResult(&sr); if (pSelectedRowCount) *pSelectedRowCount = selectedRowCount; return ffList; }