summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2014-04-17 20:49:19 +0000
committerrandomdan <randomdan@localhost>2014-04-17 20:49:19 +0000
commite2214fd1eeba02169a83ba3ee871a60075741d3c (patch)
treec7cd259d72bdc18a5b631adc141e638789019dc2
parentRemove dead tables (diff)
downloadp2pvr-e2214fd1eeba02169a83ba3ee871a60075741d3c.tar.bz2
p2pvr-e2214fd1eeba02169a83ba3ee871a60075741d3c.tar.xz
p2pvr-e2214fd1eeba02169a83ba3ee871a60075741d3c.zip
Add event search method
-rw-r--r--p2pvr/daemon/si.cpp10
-rw-r--r--p2pvr/daemon/si.h1
-rw-r--r--p2pvr/daemon/sql/SI_eventSearch.sql32
-rw-r--r--p2pvr/ice/p2pvr.ice2
4 files changed, 45 insertions, 0 deletions
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<std::string> & keywords, const IceUtil::Optional<Ice::Int> & serviceId, const IceUtil::Optional<Common::DateTime> & from, const IceUtil::Optional<Common::DateTime> & to, const Ice::Current &)
+{
+ DVBSI::Events rtn;
+ SqlContainerCreator<DVBSI::Events, DVBSI::Event> 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<std::string> & keywords, const IceUtil::Optional<Ice::Int> & serviceId, const IceUtil::Optional<Common::DateTime> & from, const IceUtil::Optional<Common::DateTime> & 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 {