2017-11-04 23:46:50 -04:00
|
|
|
"use strict";
|
|
|
|
|
2023-11-22 19:34:48 +01:00
|
|
|
const BRecentNote = require('../../becca/entities/brecent_note.js');
|
|
|
|
const sql = require('../../services/sql.js');
|
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) {
|
2023-01-03 13:52:37 +01:00
|
|
|
new BRecentNote({
|
2019-05-21 21:47:28 +02:00
|
|
|
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) {
|
2023-06-23 00:26:47 +08:00
|
|
|
// 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
|
|
|
};
|