mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
don't sync recent_notes
This commit is contained in:
parent
c0dfd23191
commit
9f19cf8046
@ -0,0 +1,14 @@
|
|||||||
|
DELETE FROM entity_changes WHERE entityName = 'recent_notes';
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "mig_recent_notes"
|
||||||
|
(
|
||||||
|
noteId TEXT not null primary key,
|
||||||
|
notePath TEXT not null,
|
||||||
|
utcDateCreated TEXT not null
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO mig_recent_notes (noteId, notePath, utcDateCreated)
|
||||||
|
SELECT noteId, notePath, utcDateCreated FROM recent_notes;
|
||||||
|
|
||||||
|
DROP TABLE recent_notes;
|
||||||
|
ALTER TABLE mig_recent_notes RENAME TO recent_notes;
|
@ -15,7 +15,7 @@ class Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('isDeleted' in this) {
|
if ('isDeleted' in this && this.constructor.entityName !== 'recent_notes') {
|
||||||
this.isDeleted = !!this.isDeleted;
|
this.isDeleted = !!this.isDeleted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,21 +8,15 @@ const dateUtils = require('../services/date_utils');
|
|||||||
*
|
*
|
||||||
* @property {string} noteId
|
* @property {string} noteId
|
||||||
* @property {string} notePath
|
* @property {string} notePath
|
||||||
* @property {boolean} isDeleted
|
* @property {string} utcDateCreated
|
||||||
* @property {string} utcDateModified
|
|
||||||
*
|
*
|
||||||
* @extends Entity
|
* @extends Entity
|
||||||
*/
|
*/
|
||||||
class RecentNote extends Entity {
|
class RecentNote extends Entity {
|
||||||
static get entityName() { return "recent_notes"; }
|
static get entityName() { return "recent_notes"; }
|
||||||
static get primaryKeyName() { return "noteId"; }
|
static get primaryKeyName() { return "noteId"; }
|
||||||
static get hashedProperties() { return ["noteId", "notePath", "utcDateCreated", "isDeleted"]; }
|
|
||||||
|
|
||||||
beforeSaving() {
|
beforeSaving() {
|
||||||
if (!this.isDeleted) {
|
|
||||||
this.isDeleted = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.utcDateCreated) {
|
if (!this.utcDateCreated) {
|
||||||
this.utcDateCreated = dateUtils.utcNowDateTime();
|
this.utcDateCreated = dateUtils.utcNowDateTime();
|
||||||
}
|
}
|
||||||
@ -31,4 +25,4 @@ class RecentNote extends Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = RecentNote;
|
module.exports = RecentNote;
|
||||||
|
@ -1,12 +1,21 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const RecentNote = require('../../entities/recent_note');
|
const RecentNote = require('../../entities/recent_note');
|
||||||
|
const sql = require('../../services/sql');
|
||||||
|
const dateUtils = require('../../services/date_utils');
|
||||||
|
|
||||||
function addRecentNote(req) {
|
function addRecentNote(req) {
|
||||||
new RecentNote({
|
new RecentNote({
|
||||||
noteId: req.body.noteId,
|
noteId: req.body.noteId,
|
||||||
notePath: req.body.notePath
|
notePath: req.body.notePath
|
||||||
}).save();
|
}).save();
|
||||||
|
|
||||||
|
if (Math.random() < 0.05) {
|
||||||
|
// it's not necessary to run this everytime ...
|
||||||
|
const cutOffDate = dateUtils.utcDateStr(new Date(Date.now() - 24 * 3600 * 1000));
|
||||||
|
|
||||||
|
sql.execute(`DELETE FROM recent_notes WHERE utcDateCreated < ?`, [cutOffDate]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -4,8 +4,8 @@ const build = require('./build');
|
|||||||
const packageJson = require('../../package');
|
const packageJson = require('../../package');
|
||||||
const {TRILIUM_DATA_DIR} = require('./data_dir');
|
const {TRILIUM_DATA_DIR} = require('./data_dir');
|
||||||
|
|
||||||
const APP_DB_VERSION = 181;
|
const APP_DB_VERSION = 182;
|
||||||
const SYNC_VERSION = 19;
|
const SYNC_VERSION = 20;
|
||||||
const CLIPPER_PROTOCOL_VERSION = "1.0";
|
const CLIPPER_PROTOCOL_VERSION = "1.0";
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -505,7 +505,6 @@ class ConsistencyChecks {
|
|||||||
this.runEntityChangeChecks("note_contents", "noteId");
|
this.runEntityChangeChecks("note_contents", "noteId");
|
||||||
this.runEntityChangeChecks("note_revisions", "noteRevisionId");
|
this.runEntityChangeChecks("note_revisions", "noteRevisionId");
|
||||||
this.runEntityChangeChecks("branches", "branchId");
|
this.runEntityChangeChecks("branches", "branchId");
|
||||||
this.runEntityChangeChecks("recent_notes", "noteId");
|
|
||||||
this.runEntityChangeChecks("attributes", "attributeId");
|
this.runEntityChangeChecks("attributes", "attributeId");
|
||||||
this.runEntityChangeChecks("api_tokens", "apiTokenId");
|
this.runEntityChangeChecks("api_tokens", "apiTokenId");
|
||||||
this.runEntityChangeChecks("options", "name");
|
this.runEntityChangeChecks("options", "name");
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
const noteCache = require('./note_cache');
|
const noteCache = require('./note_cache');
|
||||||
|
const log = require('../log');
|
||||||
const noteCacheService = require('./note_cache_service.js');
|
const noteCacheService = require('./note_cache_service.js');
|
||||||
const dateUtils = require('../date_utils');
|
const dateUtils = require('../date_utils');
|
||||||
const repository = require('../repository');
|
const repository = require('../repository');
|
||||||
@ -333,7 +334,7 @@ async function findSimilarNotes(noteId) {
|
|||||||
let value = attr.value;
|
let value = attr.value;
|
||||||
let factor = 1;
|
let factor = 1;
|
||||||
|
|
||||||
if (!value) {
|
if (!value.startsWith) {
|
||||||
log.info(`Unexpected falsy value for attribute ${JSON.stringify(attr.pojo)}`);
|
log.info(`Unexpected falsy value for attribute ${JSON.stringify(attr.pojo)}`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,10 @@ function updateEntity(entity) {
|
|||||||
sql.transactional(() => {
|
sql.transactional(() => {
|
||||||
sql.upsert(entityName, primaryKeyName, clone);
|
sql.upsert(entityName, primaryKeyName, clone);
|
||||||
|
|
||||||
|
if (entityName === 'recent_notes') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const entityId = entity[primaryKeyName];
|
const entityId = entity[primaryKeyName];
|
||||||
|
|
||||||
const isSynced = entityName !== 'options' || entity.isSynced;
|
const isSynced = entityName !== 'options' || entity.isSynced;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user