2017-11-04 23:46:50 -04:00
|
|
|
"use strict";
|
|
|
|
|
2024-07-18 21:35:17 +03:00
|
|
|
import BRecentNote from "../../becca/entities/brecent_note.js";
|
|
|
|
import sql from "../../services/sql.js";
|
|
|
|
import dateUtils from "../../services/date_utils.js";
|
2025-01-09 18:36:24 +02:00
|
|
|
import type { Request } from "express";
|
2017-11-04 23:46:50 -04:00
|
|
|
|
2024-04-06 22:07:58 +03:00
|
|
|
function addRecentNote(req: Request) {
|
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
|
|
|
}
|
|
|
|
|
2024-07-18 21:42:44 +03:00
|
|
|
export default {
|
2018-03-30 15:34:07 -04:00
|
|
|
addRecentNote
|
2020-06-20 12:31:38 +02:00
|
|
|
};
|