From bd6812d92d5b2fb5b591649269098bc39c36d984 Mon Sep 17 00:00:00 2001 From: Christopher Gurnee Date: Mon, 28 Nov 2022 17:02:13 +0000 Subject: [PATCH] Small performance improvement --- src/api/pushshift/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/api/pushshift/index.js b/src/api/pushshift/index.js index 424e631..10298ab 100644 --- a/src/api/pushshift/index.js +++ b/src/api/pushshift/index.js @@ -123,15 +123,15 @@ export const getComments = async (callback, threadID, maxComments, after = 0, be let chunks = Math.floor(maxComments / chunkSize), firstChunk = true, response, lastCreatedUtc = 1 while (true) { + let query = commentURLbyLink + threadID + if (!inBrokenRange(after)) + query += '&q=*' + if (after) + query += `&after=${after}` + if (before) + query += `&before=${before}` let delay = 0 while (true) { - let query = commentURLbyLink + threadID - if (!inBrokenRange(after)) - query += '&q=*' - if (after) - query += `&after=${after}` - if (before) - query += `&before=${before}` await pushshiftTokenBucket.waitForToken() try { response = await fetchJson(query)