trim all the things ! and generate the cover in the SQL query
This commit is contained in:
@@ -76,26 +76,30 @@ class AudioBook extends DbMapping
|
||||
$multiple = false;
|
||||
}
|
||||
|
||||
// The following query should be maintained in sync with the one in the solr data source.
|
||||
$sql = sprintf("SELECT DISTINCT
|
||||
Notices.[NoticeID] AS id,
|
||||
LTRIM(RTRIM(Notices.[Title])) AS title,
|
||||
Notices.[Author] AS author,
|
||||
LTRIM(RTRIM(Notices.[Author])) AS author,
|
||||
LTRIM(RTRIM(Notices.[NoticeNr])) AS code,
|
||||
Fields.[520] AS summary,
|
||||
REPLACE(Fields.[260b], ',', '') AS editor,
|
||||
LEFT(SUBSTRING(Fields.[260c], PATINDEX('%%[0-9]%%', Fields.[260c]), 8000), PATINDEX('%%[^0-9]%%', SUBSTRING(Fields.[260c], PATINDEX('%%[0-9]%%', Fields.[260c]), 8000) + 'X')-1) AS year,
|
||||
Fields.[300] AS media,
|
||||
Fields.[490a] AS collection,
|
||||
isbn.DisplayText AS isbn,
|
||||
LTRIM(RTRIM(isbn.DisplayText)) AS isbn,
|
||||
Fields.[901] AS reader,
|
||||
Fields.[899a] AS cover,
|
||||
'' AS category, -- supposed to come from tags 600, 610, 650, 651, 655, 690, 691, 695, 696 but always empty anyway
|
||||
item1.AcquisitionDate AS availabilityDate,
|
||||
ProducerCode.TextFre As producer,
|
||||
LTRIM(RTRIM(ProducerCode.TextFre)) As producer,
|
||||
LTRIM(RTRIM(ProducerCode.Code)) AS producerCode,
|
||||
GenreCode.TextFre As genre,
|
||||
LTRIM(RTRIM(GenreCode.TextFre)) As genre,
|
||||
LTRIM(RTRIM(GenreCode.Code)) AS genreCode,
|
||||
Notices.[coverdisplay],
|
||||
CASE
|
||||
WHEN Notices.coverdisplay = 2 THEN 'http://fichiers.bibliothequesonore.ch:8089/netbiblio/images/covers/Cover' + CAST(Notices.NoticeID AS VARCHAR) + '_Original.jpg'
|
||||
ELSE 'http://ecx.images-amazon.com/images/I/' + Fields.[899a] + '._SL320_.jpg'
|
||||
END AS cover,
|
||||
Fields.[856u] AS link,
|
||||
Fields.[856z] AS linkTitle,
|
||||
LTRIM(RTRIM(Notices.[MediaType1Code])) AS mediaType
|
||||
@@ -112,8 +116,8 @@ class AudioBook extends DbMapping
|
||||
ELSE Tag
|
||||
END AS Field,
|
||||
CASE
|
||||
WHEN Tag = '020' THEN CAST(AuthorityID AS varchar)
|
||||
ELSE ContentShortPart
|
||||
WHEN Tag = '020' THEN LTRIM(RTRIM(CAST(AuthorityID AS varchar)))
|
||||
ELSE LTRIM(RTRIM(ContentShortPart))
|
||||
END AS Data
|
||||
FROM NoticeFields
|
||||
WHERE
|
||||
@@ -150,12 +154,6 @@ class AudioBook extends DbMapping
|
||||
|
||||
$books = array();
|
||||
while($row = $result->next()) {
|
||||
if($row['coverdisplay'] == 2) {
|
||||
$row['cover'] = 'http://fichiers.bibliothequesonore.ch:8089/netbiblio/images/covers/Cover'.$row['id'].'_Original.jpg';
|
||||
} else if(strlen($row['cover']) > 0) {
|
||||
$row['cover'] = 'http://ecx.images-amazon.com/images/I/'.$row['cover'].'._SL320_.jpg';
|
||||
}
|
||||
|
||||
$books[$row['id']] = $raw ? $row : new AudioBook($row);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user