From 047cb573b0e1aa59c6c1951374874f5aca32fdc7 Mon Sep 17 00:00:00 2001 From: Hossein Mehrabi Date: Fri, 1 Sep 2023 13:19:14 +0330 Subject: [PATCH] fix: fixes #165 --- src/services/unbody/unbody.service.ts | 42 +++++---------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/src/services/unbody/unbody.service.ts b/src/services/unbody/unbody.service.ts index 4e48b28..b37ca07 100644 --- a/src/services/unbody/unbody.service.ts +++ b/src/services/unbody/unbody.service.ts @@ -924,47 +924,19 @@ export class UnbodyService { getArticlesFromSameAuthors = async ({ slug, - skip = 0, - limit = 10, authors = [], - includeDrafts, }: { slug?: string - skip?: number - limit?: number authors?: string[] - includeDrafts?: boolean }) => this.handleRequest(async () => { - const { data: docs } = await this.getArticles({ - includeDrafts, - parseContent: false, - highlighted: 'include', - ...this.helpers.args.page(skip, limit), - filter: { - operator: 'And', - operands: [ - { - operator: 'Like', - path: ['mentions'], - valueText: authors.join(' '), - }, - ...(slug - ? [ - { - operator: 'NotEqual', - valueString: slug, - path: ['slug'], - } as GetObjectsGoogleDocWhereInpObj, - ] - : []), - ], - }, - }) - - if (docs.length === 0) throw 'No data for same authors' - - return docs + await this.loadInitialData() + const { posts } = this.initialData + return posts.filter( + (post) => + post.slug !== slug && + authors.every((name) => !!post.authors.find((a) => a.name === name)), + ) as LPE.Article.Metadata[] }, []) searchBlocks = async ({