From f2098954b827ca07b0e27613f878d3df1f5564b0 Mon Sep 17 00:00:00 2001 From: nebojsa Date: Wed, 30 Sep 2009 16:32:41 +0000 Subject: [PATCH] scheduled playlists can overlap now with each subsequent one interrupting one already playing --- .../scheduler/src/PostgresqlSchedule.cxx | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/campcaster/src/products/scheduler/src/PostgresqlSchedule.cxx b/campcaster/src/products/scheduler/src/PostgresqlSchedule.cxx index 3a7aa91c2..948f445d8 100644 --- a/campcaster/src/products/scheduler/src/PostgresqlSchedule.cxx +++ b/campcaster/src/products/scheduler/src/PostgresqlSchedule.cxx @@ -97,10 +97,15 @@ const std::string PostgresqlSchedule::scheduleCountStmt = * Basically checks if the starts or ends value falls within the queried frame * or starts before and ends after the queried timeframe. *----------------------------------------------------------------------------*/ +//const std::string PostgresqlSchedule::isTimeframaAvailableStmt = +// "SELECT COUNT(*) FROM schedule WHERE " +// "((starts <= ? AND ? < ends) OR (starts < ? AND ? <= ends)) " +// "OR (? <= starts AND ends <= ?)"; + +//new criteria is that playlists cannot start at the same time const std::string PostgresqlSchedule::isTimeframaAvailableStmt = "SELECT COUNT(*) FROM schedule WHERE " - "((starts <= ? AND ? < ends) OR (starts < ? AND ? <= ends)) " - "OR (? <= starts AND ends <= ?)"; + "starts = ?"; /*------------------------------------------------------------------------------ * The SQL statement for scheduling a playlist. @@ -213,13 +218,13 @@ PostgresqlSchedule :: isTimeframeAvailable( isTimeframaAvailableStmt)); timestamp = Conversion::ptimeToTimestamp(from, Conversion::roundDown); pstmt->setTimestamp(1, *timestamp); - pstmt->setTimestamp(2, *timestamp); - pstmt->setTimestamp(5, *timestamp); - - timestamp = Conversion::ptimeToTimestamp(to, Conversion::roundUp); - pstmt->setTimestamp(3, *timestamp); - pstmt->setTimestamp(4, *timestamp); - pstmt->setTimestamp(6, *timestamp); +// pstmt->setTimestamp(2, *timestamp); +// pstmt->setTimestamp(5, *timestamp); +// +// timestamp = Conversion::ptimeToTimestamp(to, Conversion::roundUp); +// pstmt->setTimestamp(3, *timestamp); +// pstmt->setTimestamp(4, *timestamp); +// pstmt->setTimestamp(6, *timestamp); Ptr::Ref rs(pstmt->executeQuery()); result = (rs->next()) ? (rs->getLong(1) == 0) : false;