mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
24 lines
635 B
JavaScript
24 lines
635 B
JavaScript
"use strict";
|
|
|
|
const RecentNote = require('../../becca/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.utcDateTimeStr(new Date(Date.now() - 24 * 3600 * 1000));
|
|
|
|
sql.execute(`DELETE FROM recent_notes WHERE utcDateCreated < ?`, [cutOffDate]);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
addRecentNote
|
|
};
|