mirror of
https://github.com/zadam/trilium.git
synced 2025-02-22 14:03:36 +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 noteCacheService = require('../../services/note_cache');
|
||||||
const repository = require('../../services/repository');
|
const repository = require('../../services/repository');
|
||||||
|
const log = require('../../services/log');
|
||||||
|
|
||||||
async function getAutocomplete(req) {
|
async function getAutocomplete(req) {
|
||||||
const query = req.query.query;
|
const query = req.query.query;
|
||||||
|
@ -9,6 +10,8 @@ async function getAutocomplete(req) {
|
||||||
|
|
||||||
let results;
|
let results;
|
||||||
|
|
||||||
|
const timestampStarted = Date.now();
|
||||||
|
|
||||||
if (query.trim().length === 0) {
|
if (query.trim().length === 0) {
|
||||||
results = await getRecentNotes(currentNoteId);
|
results = await getRecentNotes(currentNoteId);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +19,12 @@ async function getAutocomplete(req) {
|
||||||
results = noteCacheService.findNotes(query);
|
results = noteCacheService.findNotes(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const msTaken = Date.now() - timestampStarted;
|
||||||
|
|
||||||
|
if (msTaken >= 100) {
|
||||||
|
log.info(`Slow autocomplete took ${msTaken}ms`);
|
||||||
|
}
|
||||||
|
|
||||||
return results.map(res => {
|
return results.map(res => {
|
||||||
return {
|
return {
|
||||||
value: res.path,
|
value: res.path,
|
||||||
|
|
Loading…
Reference in a new issue