perf: stop serving content in search and update since api

This commit is contained in:
Hongbo Wu 2024-08-15 21:09:40 +08:00
parent efb1feb86a
commit 3a07b21ec7
2 changed files with 4 additions and 32 deletions

View file

@ -688,14 +688,14 @@ export const updatesSinceResolver = authorized<
const sort = sortParamsToSort(sortParams)
// create a search query
const query = `updated:${startDate.toISOString()}${
const query = `${
folder ? ' in:' + folder : ''
} sort:${sort.by}-${sort.order}`
} updated:${startDate.toISOString()} sort:${sort.by}-${sort.order}`
const searchLibraryItemArgs = {
includeDeleted: true,
query,
includeContent: true, // by default include content for offline use for now
includeContent: false,
}
const libraryItems = await searchLibraryItems(
@ -703,6 +703,7 @@ export const updatesSinceResolver = authorized<
...searchLibraryItemArgs,
from: Number(startCursor),
size: size + 1, // fetch one more item to get next cursor
useFolders: query.includes('use:folders'),
},
uid
)

View file

@ -573,35 +573,6 @@ export const functionResolvers = {
return ctx.dataLoaders.highlights.load(item.id)
},
async content(item: PartialLibraryItem, _: unknown, ctx: ResolverContext) {
// convert html to the requested format if requested
if (
item.format &&
item.format !== ArticleFormat.Html &&
item.readableContent
) {
if (item.format === ArticleFormat.HighlightedMarkdown) {
// if the content is highlighted markdown, we will return markdown instead
// because the conversion is very slow and we don't want to block the response
// we will convert it to highlighted markdown in the client if needed
item.format = ArticleFormat.Markdown
}
try {
ctx.log.info(`Converting content to: ${item.format}`)
// convert html to the requested format
const converter = contentConverter(item.format)
if (converter) {
return converter(item.readableContent)
}
} catch (error) {
ctx.log.error('Error converting content', error)
}
}
return item.readableContent
},
isArchived: (item: LibraryItem) => !!item.archivedAt,
pageType: (item: LibraryItem) => item.itemType,
highlightsCount: (item: LibraryItem) => item.highlightAnnotations?.length,