From a2408faf270a242da03616de3dc5a1647046c8c9 Mon Sep 17 00:00:00 2001 From: Michael Kohler Date: Wed, 9 Jan 2019 19:34:09 +0100 Subject: [PATCH] Make sure we don't use a ton of GET query params for Kinto --- shared/db/collections/sentences-meta.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/shared/db/collections/sentences-meta.js b/shared/db/collections/sentences-meta.js index 1928e862..aad8b5ca 100644 --- a/shared/db/collections/sentences-meta.js +++ b/shared/db/collections/sentences-meta.js @@ -272,14 +272,11 @@ export default class SentencesMeta { async getAlreadyExistingSubset(language, sentences) { const idList = sentences.map(s => hash(s)); - const collection = await this.getCollection(language); - const result = await collection.listRecords({ - filters: { - in_id: idList, - }, - }); + const result = await this.getAll(language); + const existingIDs = result.map((existingSentence) => existingSentence.id); - return result.data; + const existingSubmittedSentencesIDs = idList.filter((id) => existingIDs.includes(id)); + return result.filter((existingSentence) => existingSubmittedSentencesIDs.includes(existingSentence.id)); } async getMySentences(language) {