Skip to content

Commit 56e3b42

Browse files
fix!: fetch everything thanks to pagination to bypass reversed sorting
1 parent 151ec67 commit 56e3b42

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/lib/server/github-cache.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ export class GitHubCache {
219219
* 2. calls the promise to get new data if no value is found in cache
220220
* 3. store this new value back in the cache with an optional TTL before returning the value.
221221
*
222+
* @returns a currying promise than handles everything needed for requests
222223
* @private
223224
*/
224225
#processCached<RType extends Parameters<InstanceType<typeof Redis>["json"]["set"]>[2]>() {
@@ -782,15 +783,11 @@ export class GitHubCache {
782783
this.#getRepoKey(owner, repo, "discussions"),
783784
async () => {
784785
try {
785-
const { data: discussions } = await this.#octokit.request(
786-
"GET /repos/{owner}/{repo}/discussions",
787-
{
788-
owner,
789-
repo,
790-
per_page
791-
}
792-
);
793-
return discussions;
786+
return await this.#octokit.paginate<Discussion>("GET /repos/{owner}/{repo}/discussions", {
787+
owner,
788+
repo,
789+
per_page
790+
});
794791
} catch {
795792
return [] as Discussion[];
796793
}

0 commit comments

Comments
 (0)