From 6bf9e3e95e69bce42c740bf46e0adbfa5e98031b Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Tue, 9 Jul 2024 18:21:09 +0100 Subject: [PATCH] fix: explicitly sort subjects by ID Sort subjects by ID, otherwise the paged API query can duplicate subjects across pages. --- src/projects.js | 3 ++- src/subject-set.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/projects.js b/src/projects.js index 60ba3d6..16a7097 100644 --- a/src/projects.js +++ b/src/projects.js @@ -140,7 +140,8 @@ async function fetchSubjectsByPage(projectId = '', page = 1, pageSize = 100) { const { subjects, meta } = await fetchWithRetry('/subjects', { project_id: projectId, page, - page_size: pageSize + page_size: pageSize, + sort: 'id' }) return { subjects, meta: meta.subjects } } catch (err) { diff --git a/src/subject-set.js b/src/subject-set.js index 8ee78bd..7684843 100644 --- a/src/subject-set.js +++ b/src/subject-set.js @@ -24,7 +24,8 @@ async function getPagedSubjects(subjectSet, page = 1) { const { subjects, meta } = await fetchWithRetry('/subjects', { subject_set_id: id, page_size: PAGE_SIZE, - page + page, + sort: 'id' }) const rows = subjects.map(subject => subjectMetadataRow(subject, indexFields)) if (meta.subjects.page_count > page) {