Skip to content

Commit

Permalink
fix(hosts) now sorts from shortest to longest. Also removed a bad joi…
Browse files Browse the repository at this point in the history
…n for live+working sites (#27497)

ref: #27447

Co-authored-by: Jose Castro <jose.castro@dotcms.com>
Co-authored-by: Nollymar Longa <nollymar.longa@dotcms.com>
  • Loading branch information
3 people committed Feb 7, 2024
1 parent d201a7c commit 961dfb7
Showing 1 changed file with 4 additions and 6 deletions.
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

0 comments on commit 961dfb7

Please sign in to comment.