Skip to content

Commit

Permalink
chore: improve query spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdvlpr committed Nov 11, 2024
1 parent 9d21311 commit 281b661
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/helpers/jw-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,24 +427,24 @@ const getDocumentMultimediaItems = (source: MultimediaItemsFetcher) => {
.includes('SuppressZoom');

// let select = 'SELECT Multimedia.DocumentId, Multimedia.MultimediaId, ';
const select = 'SELECT * ';
let from = 'FROM Multimedia ';
const select = 'SELECT *';
let from = 'FROM Multimedia';
if (mmTable === 'DocumentMultimedia') {
from +=
'INNER JOIN DocumentMultimedia ON DocumentMultimedia.MultimediaId = Multimedia.MultimediaId ';
from += `LEFT JOIN DocumentParagraph ON ${mmTable}.BeginParagraphOrdinal = DocumentParagraph.ParagraphIndex `;
' INNER JOIN DocumentMultimedia ON DocumentMultimedia.MultimediaId = Multimedia.MultimediaId';
from += ` LEFT JOIN DocumentParagraph ON ${mmTable}.BeginParagraphOrdinal = DocumentParagraph.ParagraphIndex`;
}
from += `INNER JOIN Document ON ${mmTable}.DocumentId = Document.DocumentId `;
from += ` INNER JOIN Document ON ${mmTable}.DocumentId = Document.DocumentId`;

let where = ` WHERE ${
let where = `WHERE ${
source.docId || source.docId === 0
? `Document.DocumentId = ${source.docId}`
: `Document.MepsDocumentId = ${source.mepsId}`
}`;

const videoString =
"(Multimedia.MimeType LIKE '%video%' OR Multimedia.MimeType LIKE '%audio%')";
const imgString = `(Multimedia.MimeType LIKE '%image%' ${
const imgString = `(Multimedia.MimeType LIKE '%image%'${
currentStateStore.currentSettings?.includePrinted
? ''
: ' AND Multimedia.CategoryType <> 4 AND Multimedia.CategoryType <> 6'
Expand All @@ -461,11 +461,11 @@ const getDocumentMultimediaItems = (source: MultimediaItemsFetcher) => {
}

const groupAndSort = ParagraphColumnsExist
? ' GROUP BY Multimedia.MultimediaId ORDER BY DocumentParagraph.BeginPosition'
? 'GROUP BY Multimedia.MultimediaId ORDER BY DocumentParagraph.BeginPosition'
: '';

if (targetParNrExists && ParagraphColumnsExist) {
from += ` LEFT JOIN Question ON Question.DocumentId = ${mmTable}.DocumentId AND Question.TargetParagraphOrdinal = ${mmTable}.BeginParagraphOrdinal `;
from += ` LEFT JOIN Question ON Question.DocumentId = ${mmTable}.DocumentId AND Question.TargetParagraphOrdinal = ${mmTable}.BeginParagraphOrdinal`;
}
if (suppressZoomExists) {
where += ' AND Multimedia.SuppressZoom <> 1';
Expand Down

0 comments on commit 281b661

Please sign in to comment.