summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2014-01-19 21:11:16 +0000
committerrandomdan <randomdan@localhost>2014-01-19 21:11:16 +0000
commit671046fbeae778b7db1ee18034c32a1b10cdd407 (patch)
treed0e292fb37e0721201113cfb97ace3f1837bcdc5
parentAdd missing collocationOptimized fix (diff)
downloadp2pvr-671046fbeae778b7db1ee18034c32a1b10cdd407.tar.bz2
p2pvr-671046fbeae778b7db1ee18034c32a1b10cdd407.tar.xz
p2pvr-671046fbeae778b7db1ee18034c32a1b10cdd407.zip
Minor fixes to scheduling
-rw-r--r--p2pvr/lib/schedules.cpp4
-rw-r--r--p2pvr/lib/sql/Schedules_GetCandidates.sql2
2 files changed, 3 insertions, 3 deletions
diff --git a/p2pvr/lib/schedules.cpp b/p2pvr/lib/schedules.cpp
index bca7ddd..d13b231 100644
--- a/p2pvr/lib/schedules.cpp
+++ b/p2pvr/lib/schedules.cpp
@@ -240,7 +240,7 @@ class SumTimeToStart {
inline void operator()(const ShowingPtr & s) const
{
if (s) {
- total += (now - s->startTime).seconds();
+ total += std::min<time_t>((now - s->startTime).seconds(), 0);
}
}
public:
@@ -263,7 +263,7 @@ EpisodeGroup::Suggest(const Showings & showings)
if (c >= score) {
time_t stt;
std::for_each(showings.begin(), showings.end(), SumTimeToStart(stt));
- if (stt < sumTimeToStart) {
+ if (stt < sumTimeToStart || (stt == sumTimeToStart && c > score)) {
if (IsShowingListValid(showings)) {
selected = showings;
score = c;
diff --git a/p2pvr/lib/sql/Schedules_GetCandidates.sql b/p2pvr/lib/sql/Schedules_GetCandidates.sql
index f7ad997..8e8b15e 100644
--- a/p2pvr/lib/sql/Schedules_GetCandidates.sql
+++ b/p2pvr/lib/sql/Schedules_GetCandidates.sql
@@ -12,7 +12,7 @@ from (
and (s.eventid is null or s.eventid = e.eventid)
and (s.search is null or event_tsvector(e) @@ plainto_tsquery(s.search))
and sv.serviceid = e.serviceid
- and e.starttime > now()
+ and e.stoptime > now()
and not exists (
select 1
from recorded r