Skip to content

Commit

Permalink
fix: explicitly sort subjects by ID
Browse files Browse the repository at this point in the history
Sort subjects by ID, otherwise the paged API query can duplicate subjects across pages.
  • Loading branch information
eatyourgreens committed Jul 10, 2024
1 parent 5dfd0cb commit 6bf9e3e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/subject-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6bf9e3e

Please sign in to comment.