Notes/src/routes/api/recent_notes.ts

25 lines
678 B
TypeScript
Raw Normal View History

2017-11-04 23:46:50 -04:00
"use strict";
import BRecentNote = require('../../becca/entities/brecent_note');
import sql = require('../../services/sql');
import dateUtils = require('../../services/date_utils');
import { Request } from 'express';
2017-11-04 23:46:50 -04:00
function addRecentNote(req: Request) {
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
}
export = {
2018-03-30 15:34:07 -04:00
addRecentNote
2020-06-20 12:31:38 +02:00
};