remove LastBooksByType from the WS

master
Gilles Crettenand 11 years ago
parent c897f2c9c6
commit afca12a232

@ -181,83 +181,6 @@ class AudioBook extends DbMapping
return $row['NoticeId']; return $row['NoticeId'];
} }
/**
* Retrieve the last books for each type. If 'type' is an empty string, then
* it returns all types.
*/
public static function lastBooksByType($type, $itemsByGroup = 10)
{
$type_before_escape = $type;
$type = Connection::escape(utf8_decode($type));
if ($type_before_escape == "Jeunesse") {
if ($itemsByGroup < 20)
$itemsByGroup = 20;
$sqlQuery = " SELECT top " . $itemsByGroup . " Notices.NoticeId AS id, ";
$sqlQuery .= " Notices.title AS title, ";
$sqlQuery .= " Notices.author AS author, ";
$sqlQuery .= " LTRIM(RTRIM(Notices.NoticeNr)) AS code, ";
$sqlQuery .= " 'Jeunesse' AS type, 0 as score, ";
$sqlQuery .= " convert(varchar, CreationDate, 102) as date ";
$sqlQuery .= " FROM Notices ";
$sqlQuery .= " WHERE Notices.NoticeNr NOT LIKE '%~%' ";
$sqlQuery .= " AND Notices.NoticeNr NOT LIKE '%V%' ";
$sqlQuery .= " AND Notices.NoticeNr NOT LIKE '%T%' ";
$sqlQuery .= " AND Notices.MediaType1Code = 'CDD' ";
$sqlQuery .= " AND Notices.Visible = 1 ";
$sqlQuery .= " AND Notices.AgeCode in ('E', 'J') ";
$sqlQuery .= " ORDER BY date DESC;";
} else {
$sqlQuery = "WITH cte AS ( ";
$sqlQuery .= " SELECT Notices.NoticeId AS id, ";
$sqlQuery .= " Notices.title AS title, ";
$sqlQuery .= " Notices.author AS author, ";
$sqlQuery .= " LTRIM(RTRIM(Notices.NoticeNr)) AS code, ";
$sqlQuery .= " Codes.TextFre AS type, ";
$sqlQuery .= " convert(varchar, CreationDate, 102) as date, ";
$sqlQuery .= " rank() OVER ( ";
$sqlQuery .= " PARTITION BY Codes.TextFre ";
$sqlQuery .= " ORDER BY cast(LTRIM(RTRIM(Notices.NoticeNr)) as int) DESC ";
$sqlQuery .= " ) AS num ";
$sqlQuery .= " FROM Notices ";
$sqlQuery .= " INNER JOIN Codes ";
$sqlQuery .= " ON Notices.MediaType2Code = Codes.Code ";
$sqlQuery .= " WHERE Codes.Type = 2 ";
if (strlen($type))
$sqlQuery .= " AND Codes.TextFre = " . $type . " ";
$sqlQuery .= " AND Notices.NoticeNr NOT LIKE '%~%' ";
$sqlQuery .= " AND Notices.NoticeNr NOT LIKE '%V%' ";
$sqlQuery .= " AND Notices.NoticeNr NOT LIKE '%T%' ";
$sqlQuery .= " AND Notices.MediaType1Code = 'CDD' ";
$sqlQuery .= " AND Notices.Visible = 1 ";
$sqlQuery .= " GROUP BY Codes.TextFre, ";
$sqlQuery .= " Notices.NoticeNr, ";
$sqlQuery .= " Notices.NoticeId, ";
$sqlQuery .= " Notices.title, ";
$sqlQuery .= " Notices.author, ";
$sqlQuery .= " Notices.CreationDate ";
$sqlQuery .= ") ";
$sqlQuery .= "SELECT id, title, author, code, type, 0 as score, date ";
$sqlQuery .= "FROM cte ";
$sqlQuery .= "WHERE num <= " . intval($itemsByGroup) . " ";
$sqlQuery .= "ORDER BY date DESC;";
}
$resultSet = Connection::execute($sqlQuery);
$result = array();
while (($row = $resultSet->next()))
$result[] = new AudioBook($row, TRUE);
return $result;
}
/** /**
* Retrieve the list of all readers (volunteers) having read at least 4 books (2 notices per book). * Retrieve the list of all readers (volunteers) having read at least 4 books (2 notices per book).
* Returns an associative array containing $lastname and $firstname * Returns an associative array containing $lastname and $firstname
@ -267,7 +190,7 @@ class AudioBook extends DbMapping
$sql = "SELECT $sql = "SELECT
count(*), count(*),
ContentShortPart AS name ContentShortPart AS name
FROM noticefields FROM NoticeFields
WHERE Tag=901 WHERE Tag=901
GROUP BY ContentShortPart GROUP BY ContentShortPart
HAVING count(*) > 6 HAVING count(*) > 6

@ -378,17 +378,6 @@ class NetBiblio extends WebService
}); });
} }
public function LastBooksByType($type, $itemsByGroup)
{
$this->checkSession();
$books = AudioBook::lastBooksByType($type, $itemsByGroup);
$books = array_map(array($this, 'AddFiles'), $books);
foreach ($books as $book) {
$this->data[$book['type']][] = $book;
}
}
public function InReadingBooks() public function InReadingBooks()
{ {
$this->data = AudioBook::inReading(); $this->data = AudioBook::inReading();

Loading…
Cancel
Save