optimized edited notes on day query

This commit is contained in:
zadam 2019-12-01 14:30:59 +01:00
parent 35cd7f3261
commit 4c07ac4c4c

View file

@ -115,12 +115,17 @@ async function getEditedNotesOnDate(req) {
const date = utils.sanitizeSql(req.params.date);
const notes = await repository.getEntities(`
select distinct notes.*
from notes
left join note_revisions using (noteId)
where notes.dateCreated LIKE '${date}%'
OR notes.dateModified LIKE '${date}%'
OR note_revisions.dateLastEdited LIKE '${date}%'`);
SELECT notes.*
FROM notes
WHERE noteId IN (
SELECT noteId FROM notes
WHERE notes.dateCreated LIKE '${date}%'
OR notes.dateModified LIKE '${date}%'
UNION ALL
SELECT noteId FROM note_revisions
WHERE note_revisions.dateLastEdited LIKE '${date}%'
)
ORDER BY isDeleted`);
for (const note of notes) {
const notePath = noteCacheService.getNotePath(note.noteId);