2019-04-14 12:18:52 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const dateNoteService = require('../../services/date_notes');
|
2019-09-08 16:30:33 +02:00
|
|
|
const sql = require('../../services/sql');
|
2021-02-26 23:33:22 +01:00
|
|
|
const cls = require('../../services/cls');
|
2021-09-16 22:09:39 +02:00
|
|
|
const specialNotesService = require('../../services/special_notes');
|
2021-06-05 23:35:47 +02:00
|
|
|
const becca = require('../../becca/becca');
|
2020-11-27 22:21:13 +01:00
|
|
|
|
|
|
|
function getInboxNote(req) {
|
2021-09-16 22:09:39 +02:00
|
|
|
return specialNotesService.getInboxNote(req.params.date);
|
2020-11-27 22:21:13 +01:00
|
|
|
}
|
2019-04-14 12:18:52 +02:00
|
|
|
|
2022-01-10 17:09:20 +01:00
|
|
|
function getDayNote(req) {
|
|
|
|
return dateNoteService.getDayNote(req.params.date);
|
2019-04-14 12:18:52 +02:00
|
|
|
}
|
|
|
|
|
2021-10-21 03:16:51 -07:00
|
|
|
function getWeekNote(req) {
|
|
|
|
return dateNoteService.getWeekNote(req.params.date);
|
|
|
|
}
|
|
|
|
|
2020-06-20 12:31:38 +02:00
|
|
|
function getMonthNote(req) {
|
|
|
|
return dateNoteService.getMonthNote(req.params.month);
|
2019-04-14 12:18:52 +02:00
|
|
|
}
|
|
|
|
|
2020-06-20 12:31:38 +02:00
|
|
|
function getYearNote(req) {
|
|
|
|
return dateNoteService.getYearNote(req.params.year);
|
2019-04-14 12:18:52 +02:00
|
|
|
}
|
|
|
|
|
2022-01-10 17:09:20 +01:00
|
|
|
function getDayNotesForMonth(req) {
|
2019-09-08 16:30:33 +02:00
|
|
|
const month = req.params.month;
|
|
|
|
|
|
|
|
return sql.getMap(`
|
|
|
|
SELECT
|
|
|
|
attr.value AS date,
|
|
|
|
notes.noteId
|
|
|
|
FROM notes
|
|
|
|
JOIN attributes attr USING(noteId)
|
|
|
|
WHERE notes.isDeleted = 0
|
|
|
|
AND attr.isDeleted = 0
|
|
|
|
AND attr.type = 'label'
|
|
|
|
AND attr.name = 'dateNote'
|
|
|
|
AND attr.value LIKE '${month}%'`);
|
|
|
|
}
|
|
|
|
|
2021-06-06 13:38:01 +02:00
|
|
|
function saveSqlConsole(req) {
|
2021-09-16 22:09:39 +02:00
|
|
|
return specialNotesService.saveSqlConsole(req.body.sqlConsoleNoteId);
|
2021-06-06 13:38:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function createSqlConsole() {
|
2021-09-16 22:09:39 +02:00
|
|
|
return specialNotesService.createSqlConsole();
|
2021-06-06 13:38:01 +02:00
|
|
|
}
|
|
|
|
|
2021-06-06 11:01:10 +02:00
|
|
|
function saveSearchNote(req) {
|
2021-09-16 22:09:39 +02:00
|
|
|
return specialNotesService.saveSearchNote(req.body.searchNoteId);
|
2021-06-06 11:01:10 +02:00
|
|
|
}
|
|
|
|
|
2021-06-05 23:35:47 +02:00
|
|
|
function createSearchNote(req) {
|
|
|
|
const hoistedNote = getHoistedNote();
|
2021-09-16 22:09:39 +02:00
|
|
|
const searchString = req.body.searchString || "";
|
|
|
|
const ancestorNoteId = req.body.ancestorNoteId || hoistedNote.noteId;
|
2021-02-25 20:02:49 +01:00
|
|
|
|
2021-09-16 22:09:39 +02:00
|
|
|
return specialNotesService.createSearchNote(searchString, ancestorNoteId);
|
2020-10-25 23:02:12 +01:00
|
|
|
}
|
|
|
|
|
2021-03-12 21:29:50 +01:00
|
|
|
function getHoistedNote() {
|
2021-06-06 11:01:10 +02:00
|
|
|
return becca.getNote(cls.getHoistedNoteId());
|
2021-03-12 21:29:50 +01:00
|
|
|
}
|
|
|
|
|
2022-08-07 13:23:03 +02:00
|
|
|
function createShortcut(req) {
|
2022-11-29 16:16:57 +01:00
|
|
|
return specialNotesService.createShortcut(req.params.parentNoteId, req.params.shortcutType);
|
2022-08-07 13:23:03 +02:00
|
|
|
}
|
|
|
|
|
2022-11-25 15:29:57 +01:00
|
|
|
function resetShortcut(req) {
|
|
|
|
return specialNotesService.resetShortcut(req.params.noteId);
|
|
|
|
}
|
|
|
|
|
2019-04-14 12:18:52 +02:00
|
|
|
module.exports = {
|
2020-11-27 22:21:13 +01:00
|
|
|
getInboxNote,
|
2022-01-10 17:09:20 +01:00
|
|
|
getDayNote,
|
2021-10-21 03:16:51 -07:00
|
|
|
getWeekNote,
|
2019-04-14 12:18:52 +02:00
|
|
|
getMonthNote,
|
2019-09-08 16:30:33 +02:00
|
|
|
getYearNote,
|
2022-01-10 17:09:20 +01:00
|
|
|
getDayNotesForMonth,
|
2020-10-25 23:02:12 +01:00
|
|
|
createSqlConsole,
|
2021-06-06 13:38:01 +02:00
|
|
|
saveSqlConsole,
|
2021-06-06 11:01:10 +02:00
|
|
|
createSearchNote,
|
2022-08-07 13:23:03 +02:00
|
|
|
saveSearchNote,
|
2022-11-25 15:29:57 +01:00
|
|
|
createShortcut,
|
|
|
|
resetShortcut
|
2020-06-20 12:31:38 +02:00
|
|
|
};
|