Skip to content

Commit

Permalink
feat: only extract media for a specific date
Browse files Browse the repository at this point in the history
  • Loading branch information
BenShelton committed Mar 30, 2021
1 parent 436859d commit 591a9c6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib/Publication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ export class Publication {
}

async getMedia (date: string): Promise<MediaRow[]> {
// TODO: Extract Media for that date
const offsetDate = date.replace(/-/g, '')
const query = `
SELECT D.ContextTitle, M.Caption, M.FilePath
FROM Multimedia M
JOIN DocumentMultimedia DM ON M.MultimediaId = DM.MultimediaId
JOIN Document D ON DM.DocumentId = D.DocumentId
WHERE D.Class IS ${PUBLICATION_CLASSES.WATCHTOWER_ARTICLE}`
INNER JOIN Document D ON DM.DocumentId = D.DocumentId
INNER JOIN InternalLink IL ON IL.MepsDocumentId = D.MepsDocumentId
INNER JOIN DocumentInternalLink AS DIL ON DIL.InternalLinkId = IL.InternalLinkId
INNER JOIN DatedText AS DT ON DT.EndParagraphOrdinal = DIL.EndParagraphOrdinal
WHERE DT.FirstDateOffset <= '${offsetDate}' AND DT.LastDateOffset >= '${offsetDate}'`
const db = await this.getDatabase()
const rows = await db.all<MediaRow[]>(query)
return rows
Expand Down

0 comments on commit 591a9c6

Please # to comment.