adding few missing isErased = 0 conditions

This commit is contained in:
zadam 2020-12-10 21:56:48 +01:00
parent 0ac42608f7
commit 5010175b84
3 changed files with 5 additions and 4 deletions

View File

@ -776,7 +776,7 @@ class Note extends Entity {
* @returns {NoteRevision[]} * @returns {NoteRevision[]}
*/ */
getRevisions() { getRevisions() {
return this.repository.getEntities("SELECT * FROM note_revisions WHERE noteId = ?", [this.noteId]); return this.repository.getEntities("SELECT * FROM note_revisions WHERE isErased = 0 AND noteId = ?", [this.noteId]);
} }
/** /**
@ -806,7 +806,7 @@ class Note extends Entity {
* @returns {boolean} - true if note has children * @returns {boolean} - true if note has children
*/ */
hasChildren() { hasChildren() {
return (this.getChildNotes()).length > 0; return this.getChildNotes().length > 0;
} }
/** /**

View File

@ -23,7 +23,8 @@ function getRecentChanges(req) {
note_revisions.dateCreated AS date note_revisions.dateCreated AS date
FROM FROM
note_revisions note_revisions
JOIN notes USING(noteId)`); JOIN notes USING(noteId)
WHERE note_revisions.isErased = 0`);
for (const noteRevision of noteRevisions) { for (const noteRevision of noteRevisions) {
if (noteCacheService.isInAncestor(noteRevision.noteId, ancestorNoteId)) { if (noteCacheService.isInAncestor(noteRevision.noteId, ancestorNoteId)) {

View File

@ -468,7 +468,7 @@ function saveNoteRevision(note) {
const revisionCutoff = dateUtils.utcDateStr(new Date(now.getTime() - noteRevisionSnapshotTimeInterval * 1000)); const revisionCutoff = dateUtils.utcDateStr(new Date(now.getTime() - noteRevisionSnapshotTimeInterval * 1000));
const existingNoteRevisionId = sql.getValue( const existingNoteRevisionId = sql.getValue(
"SELECT noteRevisionId FROM note_revisions WHERE noteId = ? AND utcDateCreated >= ?", [note.noteId, revisionCutoff]); "SELECT noteRevisionId FROM note_revisions WHERE noteId = ? AND isErased = 0 AND utcDateCreated >= ?", [note.noteId, revisionCutoff]);
const msSinceDateCreated = now.getTime() - dateUtils.parseDateTime(note.utcDateCreated).getTime(); const msSinceDateCreated = now.getTime() - dateUtils.parseDateTime(note.utcDateCreated).getTime();