From 845907b8d2b6724f4066070773fb280cdd22a5fa Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 17 Nov 2020 21:06:38 +0100 Subject: [PATCH] fix recent changes to show all deleted notes (also without note revisions) --- src/routes/api/recent_changes.js | 41 ++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/src/routes/api/recent_changes.js b/src/routes/api/recent_changes.js index 1a8e1a331a..3f6b9c5399 100644 --- a/src/routes/api/recent_changes.js +++ b/src/routes/api/recent_changes.js @@ -31,19 +31,36 @@ function getRecentChanges(req) { } } + // now we need to also collect date points not represented in note revisions: + // 1. creation for all notes (dateCreated) + // 2. deletion for deleted notes (dateModified) const notes = sql.getRows(` - SELECT - notes.noteId, - notes.isDeleted AS current_isDeleted, - notes.deleteId AS current_deleteId, - notes.isErased AS current_isErased, - notes.title AS current_title, - notes.isProtected AS current_isProtected, - notes.title, - notes.utcDateCreated AS utcDate, - notes.dateCreated AS date - FROM - notes`); + SELECT + notes.noteId, + notes.isDeleted AS current_isDeleted, + notes.deleteId AS current_deleteId, + notes.isErased AS current_isErased, + notes.title AS current_title, + notes.isProtected AS current_isProtected, + notes.title, + notes.utcDateCreated AS utcDate, + notes.dateCreated AS date + FROM + notes + UNION ALL + SELECT + notes.noteId, + notes.isDeleted AS current_isDeleted, + notes.deleteId AS current_deleteId, + notes.isErased AS current_isErased, + notes.title AS current_title, + notes.isProtected AS current_isProtected, + notes.title, + notes.utcDateModified AS utcDate, + notes.dateModified AS date + FROM + notes + WHERE notes.isDeleted = 1 AND notes.isErased = 0`); for (const note of notes) { if (noteCacheService.isInAncestor(note.noteId, ancestorNoteId)) {