Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hosts) now sorts from shortest to longest. Also removed a bad jo… #27497

Merged
merged 4 commits into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ public class HostFactoryImpl implements HostFactory {

private static final String SITE_IS_LIVE = "cvi.live_inode IS NOT NULL";
@VisibleForTesting
protected static final String SITE_IS_LIVE_OR_STOPPED = "cvi.live_inode IS NOT null or " +
"(cvi.live_inode IS NULL AND cvi.deleted = false )";
protected static final String SITE_IS_LIVE_OR_STOPPED = "cvi.deleted = false";
private static final String SITE_IS_STOPPED = "cvi.live_inode IS NULL AND cvi" +
".deleted = " +
getDBFalse();
Expand All @@ -137,7 +136,7 @@ public class HostFactoryImpl implements HostFactory {

// query that Exact matches should be at the top of the search results.
private static final String PRIORITIZE_EXACT_MATCHES =
"ORDER BY CASE WHEN LOWER(%s) = ? THEN 0 ELSE 1 END";
"ORDER BY length(%s) ";

/**
* Default class constructor.
Expand Down Expand Up @@ -771,9 +770,8 @@ protected Optional<List<Host>> search(final String siteNameFilter, final String
dc.setSQL(sqlQuery.toString());
if (UtilMethods.isSet(siteNameFilter)) {
// Add the site name filter parameter
dc.addParam("%" + siteNameFilter.trim() + "%");
// Add the site name filter parameter again, but this time for the exact match
dc.addParam(siteNameFilter.trim().replace("%", ""));
dc.addParam(("%" + siteNameFilter.trim() + "%").replace("%%", "%"));

}
if (limit > 0) {
dc.setMaxRows(limit);
Expand Down
Loading