2019-09-01 08:58:13 +02:00
|
|
|
"use strict";
|
|
|
|
|
2021-06-29 22:15:57 +02:00
|
|
|
const similarityService = require('../../becca/similarity');
|
|
|
|
const becca = require("../../becca/becca");
|
2022-12-09 16:13:22 +01:00
|
|
|
const NotFoundError = require("../../errors/not_found_error");
|
2019-09-01 08:58:13 +02:00
|
|
|
|
2020-09-10 21:01:46 +02:00
|
|
|
async function getSimilarNotes(req) {
|
2019-09-01 08:58:13 +02:00
|
|
|
const noteId = req.params.noteId;
|
|
|
|
|
2021-05-02 11:23:58 +02:00
|
|
|
const note = becca.getNote(noteId);
|
2019-09-01 08:58:13 +02:00
|
|
|
|
|
|
|
if (!note) {
|
2022-12-09 16:04:13 +01:00
|
|
|
throw new NotFoundError(`Note '${noteId}' not found.`);
|
2019-09-01 08:58:13 +02:00
|
|
|
}
|
|
|
|
|
2020-09-15 22:46:51 +02:00
|
|
|
return await similarityService.findSimilarNotes(noteId);
|
2019-09-01 08:58:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
getSimilarNotes
|
2020-05-13 14:42:16 +02:00
|
|
|
};
|