PR#2355 Continued + expanded scope (#2365)

* #2317 Fetch pinned documents once per folder to reduce the number of queries.

* Reorder the lines to keeps const declarations together.

* Add some comments to functions
move pinned document fetch for folder to function
move watched documents per-folder to also function the same
remove unused function in documents model

---------

Co-authored-by: Błażej Owczarczyk <blazeyy@gmail.com>
This commit is contained in:
Timothy Carambat
2024-09-24 15:55:54 -07:00
committed by GitHub
parent ac91d0df9a
commit b44889a843
3 changed files with 89 additions and 32 deletions

View File

@@ -38,6 +38,13 @@ const DocumentSyncQueue = {
return new Date(Number(new Date()) + queueRecord.staleAfterMs);
},
/**
* Check if the document can be watched based on the metadata fields
* @param {object} metadata - metadata to check
* @param {string} metadata.title - title of the document
* @param {string} metadata.chunkSource - chunk source of the document
* @returns {boolean} - true if the document can be watched, false otherwise
*/
canWatch: function ({ title, chunkSource = null } = {}) {
if (chunkSource.startsWith("link://") && title.endsWith(".html"))
return true; // If is web-link material (prior to feature most chunkSources were links://)