don't sync recent_notes

This commit is contained in:
zadam
2021-02-12 22:39:38 +01:00
parent c0dfd23191
commit 9f19cf8046
8 changed files with 34 additions and 13 deletions

View File

@@ -1,12 +1,21 @@
"use strict";
const RecentNote = require('../../entities/recent_note');
const sql = require('../../services/sql');
const dateUtils = require('../../services/date_utils');
function addRecentNote(req) {
new RecentNote({
noteId: req.body.noteId,
notePath: req.body.notePath
}).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 = {