From c5e28ee06ed73688f815f32eceaae52c8efdc56f Mon Sep 17 00:00:00 2001 From: randomdan Date: Fri, 25 Apr 2014 13:09:04 +0000 Subject: Fix the order by clause to group events correctly --- p2pvr/daemon/si.cpp | 2 +- p2pvr/daemon/sql/SI_eventSearch.sql | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/p2pvr/daemon/si.cpp b/p2pvr/daemon/si.cpp index 26f7808..9bda6c4 100644 --- a/p2pvr/daemon/si.cpp +++ b/p2pvr/daemon/si.cpp @@ -133,7 +133,7 @@ SI::EventSearch(const IceUtil::Optional & keywords, const IceUtil:: { DVBSI::Events rtn; SqlContainerCreator cc(rtn); - cc.populate(Select(SI_eventSearch, from, to, serviceId, serviceId, keywords, keywords, keywords).second); + cc.populate(Select(SI_eventSearch, from, to, serviceId, serviceId, keywords, keywords, keywords, keywords).second); return rtn; } diff --git a/p2pvr/daemon/sql/SI_eventSearch.sql b/p2pvr/daemon/sql/SI_eventSearch.sql index 5d14a98..3a43b41 100644 --- a/p2pvr/daemon/sql/SI_eventSearch.sql +++ b/p2pvr/daemon/sql/SI_eventSearch.sql @@ -27,6 +27,8 @@ from events e where tsrange(?, ?, '[)') && tsrange(e.starttime, e.stoptime) and (e.serviceId = ? or ?::int is null) and (event_tsvector(e) @@ plainto_tsquery(?) or ?::text is null) -order by max(ts_rank(event_tsvector(e), plainto_tsquery(?::text))) over(order by title, subtitle, description) desc, +order by + max(ts_rank(event_tsvector(e), plainto_tsquery(?))) over(partition by title) desc, + max(ts_rank(event_tsvector(e), plainto_tsquery(?))) over(partition by title, subtitle, description) desc, e.title, e.subtitle, e.starttime, e.serviceId, e.eventId -- cgit v1.2.3