Notes/src/routes/api/recent_notes.js

24 lines
642 B
JavaScript
Raw Normal View History

2017-11-04 23:46:50 -04:00
"use strict";
const BRecentNote = require('../../becca/entities/brecent_note.js');
2024-02-16 22:44:12 +02:00
const sql = require('../../services/sql');
2024-02-16 21:38:09 +02:00
const dateUtils = require('../../services/date_utils');
2017-11-04 23:46:50 -04:00
2020-06-20 12:31:38 +02:00
function addRecentNote(req) {
new BRecentNote({
noteId: req.body.noteId,
notePath: req.body.notePath
2018-04-02 22:53:01 -04:00
}).save();
2021-02-12 22:39:38 +01:00
if (Math.random() < 0.05) {
// it's not necessary to run this every time ...
2021-11-04 19:52:00 +01:00
const cutOffDate = dateUtils.utcDateTimeStr(new Date(Date.now() - 24 * 3600 * 1000));
2021-02-12 22:39:38 +01:00
sql.execute(`DELETE FROM recent_notes WHERE utcDateCreated < ?`, [cutOffDate]);
}
2018-03-30 15:34:07 -04:00
}
module.exports = {
addRecentNote
2020-06-20 12:31:38 +02:00
};