diff options
-rw-r--r-- | p2pvr/lib/schedules.cpp | 4 | ||||
-rw-r--r-- | p2pvr/lib/sql/Schedules_GetCandidates.sql | 2 |
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 |