mirror of
https://github.com/zadam/trilium.git
synced 2025-02-20 21:13:11 +08:00
logging slow autocomplete times
This commit is contained in:
parent
26b9302267
commit
607c821cac
1 changed files with 9 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
const noteCacheService = require('../../services/note_cache');
|
||||
const repository = require('../../services/repository');
|
||||
const log = require('../../services/log');
|
||||
|
||||
async function getAutocomplete(req) {
|
||||
const query = req.query.query;
|
||||
|
@ -9,6 +10,8 @@ async function getAutocomplete(req) {
|
|||
|
||||
let results;
|
||||
|
||||
const timestampStarted = Date.now();
|
||||
|
||||
if (query.trim().length === 0) {
|
||||
results = await getRecentNotes(currentNoteId);
|
||||
}
|
||||
|
@ -16,6 +19,12 @@ async function getAutocomplete(req) {
|
|||
results = noteCacheService.findNotes(query);
|
||||
}
|
||||
|
||||
const msTaken = Date.now() - timestampStarted;
|
||||
|
||||
if (msTaken >= 100) {
|
||||
log.info(`Slow autocomplete took ${msTaken}ms`);
|
||||
}
|
||||
|
||||
return results.map(res => {
|
||||
return {
|
||||
value: res.path,
|
||||
|
|
Loading…
Reference in a new issue