[open-ils-commits] r14005 - trunk/Open-ILS/src/sql/Pg (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Sep 10 12:21:36 EDT 2009
Author: miker
Date: 2009-09-10 12:21:33 -0400 (Thu, 10 Sep 2009)
New Revision: 14005
Modified:
trunk/Open-ILS/src/sql/Pg/300.schema.staged_search.sql
Log:
reverse-choro-date1 tiebreaker on search sorts
Modified: trunk/Open-ILS/src/sql/Pg/300.schema.staged_search.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/300.schema.staged_search.sql 2009-09-09 21:15:08 UTC (rev 14004)
+++ trunk/Open-ILS/src/sql/Pg/300.schema.staged_search.sql 2009-09-10 16:21:33 UTC (rev 14005)
@@ -301,7 +301,8 @@
sort_desc := NOT COALESCE(param_sort_desc, FALSE);
END IF;
- select_clause := select_clause || current_rank || ' AS rank';
+ select_clause := select_clause || current_rank || ' AS rank, ' ||
+ $$ COALESCE( FIRST(NULLIF(REGEXP_REPLACE(mrd.date1, E'\\D+', '0', 'g'),'')), '0' )::INT AS tie_break $$;
-- now add the other qualifiers
IF param_audience IS NOT NULL AND array_upper(param_audience, 1) > 0 THEN
@@ -349,7 +350,8 @@
END IF;
core_rel_query := select_clause || from_clause || where_clause ||
- ' GROUP BY 1 ORDER BY 4' || CASE WHEN sort_desc THEN ' DESC' ELSE ' ASC' END || ';';
+ ' GROUP BY 1 ORDER BY 4 ' || CASE WHEN sort_desc THEN 'DESC' ELSE 'ASC' END || ', 5 DESC;';
+
--RAISE NOTICE 'Base Query: %', core_rel_query;
IF param_search_ou > 0 THEN
More information about the open-ils-commits
mailing list