2019-09-01 08:58:13 +02:00
|
|
|
"use strict";
|
|
|
|
|
2021-04-16 23:01:56 +02:00
|
|
|
const similarityService = require('../../services/becca/similarity.js');
|
2019-09-01 08:58:13 +02:00
|
|
|
const repository = require('../../services/repository');
|
|
|
|
|
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;
|
|
|
|
|
2020-06-20 12:31:38 +02:00
|
|
|
const note = repository.getNote(noteId);
|
2019-09-01 08:58:13 +02:00
|
|
|
|
|
|
|
if (!note) {
|
|
|
|
return [404, `Note ${noteId} not found.`];
|
|
|
|
}
|
|
|
|
|
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
|
|
|
};
|