move entity hash to entity_changes table WIP

This commit is contained in:
zadam
2020-12-07 23:04:17 +01:00
parent 16c4b8aa43
commit 7f3ef2cb8b
14 changed files with 107 additions and 115 deletions

View File

@@ -109,9 +109,7 @@ class Attribute extends Entity {
super.beforeSaving();
if (this.isChanged) {
this.utcDateModified = dateUtils.utcNowDateTime();
}
this.utcDateModified = dateUtils.utcNowDateTime();
}
createClone(type, name, value, isInheritable) {

View File

@@ -57,9 +57,7 @@ class Branch extends Entity {
super.beforeSaving();
if (this.isChanged) {
this.utcDateModified = dateUtils.utcNowDateTime();
}
this.utcDateModified = dateUtils.utcNowDateTime();
}
createClone(parentNoteId, notePosition) {

View File

@@ -22,11 +22,6 @@ class Entity {
beforeSaving() {
this.generateIdIfNecessary();
const origHash = this.hash;
this.hash = this.generateHash();
this.isChanged = origHash !== this.hash;
}
generateIdIfNecessary() {

View File

@@ -143,8 +143,7 @@ class Note extends Entity {
noteId: this.noteId,
content: content,
dateModified: dateUtils.localNowDateTime(),
utcDateModified: dateUtils.utcNowDateTime(),
hash: utils.hash(this.noteId + "|" + content.toString())
utcDateModified: dateUtils.utcNowDateTime()
};
if (this.isProtected) {
@@ -158,7 +157,9 @@ class Note extends Entity {
sql.upsert("note_contents", "noteId", pojo);
entityChangesService.addNoteContentEntityChange(this.noteId);
const hash = utils.hash(this.noteId + "|" + content.toString());
entityChangesService.addEntityChange('note_contents', this.noteId, hash);
}
setJsonContent(content) {
@@ -904,10 +905,8 @@ class Note extends Entity {
super.beforeSaving();
if (this.isChanged) {
this.dateModified = dateUtils.localNowDateTime();
this.utcDateModified = dateUtils.utcNowDateTime();
}
this.dateModified = dateUtils.localNowDateTime();
this.utcDateModified = dateUtils.utcNowDateTime();
}
// cannot be static!

View File

@@ -106,8 +106,7 @@ class NoteRevision extends Entity {
const pojo = {
noteRevisionId: this.noteRevisionId,
content: content,
utcDateModified: dateUtils.utcNowDateTime(),
hash: utils.hash(this.noteRevisionId + "|" + content)
utcDateModified: dateUtils.utcNowDateTime()
};
if (this.isProtected) {
@@ -121,15 +120,15 @@ class NoteRevision extends Entity {
sql.upsert("note_revision_contents", "noteRevisionId", pojo);
entityChangesService.addNoteRevisionContentEntityChange(this.noteRevisionId);
const hash = utils.hash(this.noteRevisionId + "|" + content);
entityChangesService.addEntityChange('note_revision_contents', this.noteRevisionId, hash);
}
beforeSaving() {
super.beforeSaving();
if (this.isChanged) {
this.utcDateModified = dateUtils.utcNowDateTime();
}
this.utcDateModified = dateUtils.utcNowDateTime();
}
// cannot be static!

View File

@@ -32,10 +32,8 @@ class Option extends Entity {
super.beforeSaving();
if (this.isChanged) {
this.utcDateModified = dateUtils.utcNowDateTime();
}
this.utcDateModified = dateUtils.utcNowDateTime();
}
}
module.exports = Option;
module.exports = Option;