From e2214fd1eeba02169a83ba3ee871a60075741d3c Mon Sep 17 00:00:00 2001 From: randomdan Date: Thu, 17 Apr 2014 20:49:19 +0000 Subject: Add event search method --- p2pvr/daemon/si.cpp | 10 ++++++++++ p2pvr/daemon/si.h | 1 + p2pvr/daemon/sql/SI_eventSearch.sql | 32 ++++++++++++++++++++++++++++++++ p2pvr/ice/p2pvr.ice | 2 ++ 4 files changed, 45 insertions(+) create mode 100644 p2pvr/daemon/sql/SI_eventSearch.sql diff --git a/p2pvr/daemon/si.cpp b/p2pvr/daemon/si.cpp index 557003c..dda2275 100644 --- a/p2pvr/daemon/si.cpp +++ b/p2pvr/daemon/si.cpp @@ -12,6 +12,7 @@ ResourceString(SI_servicesSelectById, daemon_sql_SI_servicesSelectById_sql); ResourceString(SI_eventById, daemon_sql_SI_eventById_sql); ResourceString(SI_eventsOnNow, daemon_sql_SI_eventsOnNow_sql); ResourceString(SI_eventsInRange, daemon_sql_SI_eventsInRange_sql); +ResourceString(SI_eventSearch, daemon_sql_SI_eventSearch_sql); P2PVR::Deliveries SI::GetAllDeliveries(short type, const Ice::Current &) @@ -125,3 +126,12 @@ SI::EventsInRange(const Common::DateTime & from, const Common::DateTime & to, co return rtn; } +DVBSI::Events +SI::EventSearch(const IceUtil::Optional & keywords, const IceUtil::Optional & serviceId, const IceUtil::Optional & from, const IceUtil::Optional & to, const Ice::Current &) +{ + DVBSI::Events rtn; + SqlContainerCreator cc(rtn); + cc.populate(Select(SI_eventSearch, from, to, serviceId, serviceId, keywords, keywords, keywords).second); + return rtn; +} + diff --git a/p2pvr/daemon/si.h b/p2pvr/daemon/si.h index 6b720dc..c4a0f11 100644 --- a/p2pvr/daemon/si.h +++ b/p2pvr/daemon/si.h @@ -17,6 +17,7 @@ class SI : public P2PVR::SI, public DatabaseClient { DVBSI::EventPtr GetEvent(int serviceId, int eventId, const Ice::Current &); DVBSI::Events EventsOnNow(const Ice::Current &); DVBSI::Events EventsInRange(const Common::DateTime &, const Common::DateTime &, const Ice::Current &); + DVBSI::Events EventSearch(const IceUtil::Optional & keywords, const IceUtil::Optional & serviceId, const IceUtil::Optional & from, const IceUtil::Optional & to, const Ice::Current &); }; #endif diff --git a/p2pvr/daemon/sql/SI_eventSearch.sql b/p2pvr/daemon/sql/SI_eventSearch.sql new file mode 100644 index 0000000..5d14a98 --- /dev/null +++ b/p2pvr/daemon/sql/SI_eventSearch.sql @@ -0,0 +1,32 @@ +select + e.serviceid, + e.eventid, + e.title, + e.titlelang, + e.subtitle, + e.description, + e.descriptionlang, + e.videoaspect, + e.videoframerate, + e.videohd, + e.audiochannels, + e.audiolanguage, + e.subtitlelanguage, + e.category, + e.subcategory, + e.usercategory, + e.dvbrating, + e.starttime, + e.stoptime, + e.episode, + e.episodes, + e.year, + e.flags, + e.season +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, + e.title, e.subtitle, e.starttime, e.serviceId, e.eventId + diff --git a/p2pvr/ice/p2pvr.ice b/p2pvr/ice/p2pvr.ice index 6b9d31b..7176e72 100644 --- a/p2pvr/ice/p2pvr.ice +++ b/p2pvr/ice/p2pvr.ice @@ -111,6 +111,8 @@ module P2PVR { idempotent DVBSI::Events EventsOnNow(); ["project2:rows"] idempotent DVBSI::Events EventsInRange(Common::DateTime from, Common::DateTime to); + ["project2:rows"] + idempotent DVBSI::Events EventSearch(optional(1) string keywords, optional(2) int serviceId, optional(3) Common::DateTime from, optional(4) Common::DateTime to); }; interface Recorder { -- cgit v1.2.3