Skip to content

Commit

Permalink
Merge pull request #150 from bcgsc/Bugfix/KBDEV-1200-ClinicalTrialsgo…
Browse files Browse the repository at this point in the history
…v-loaded-records-repeatedly

Bugfix/KBDEV-1200-ClinicalTrialsgov-loaded-records-repeatedly
  • Loading branch information
sshugsc authored Apr 18, 2024
2 parents dee7eda + ce9e5ef commit 27511ed
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/clinicaltrialsgov/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ const formatDate = (date) => `${date.getFullYear()}-${date.getMonth() + 1}-${dat
const upload = async ({ conn, maxRecords, days }) => {
const source = await conn.addSource(SOURCE_DEFN);

let options = {};
let options,
optionsWithToken;

if (days) {
const startDate = new Date(Date.now() - days * 24 * 60 * 60 * 1000);
Expand All @@ -320,7 +321,9 @@ const upload = async ({ conn, maxRecords, days }) => {

while (next) {
if (nextToken) {
options = { pageToken: nextToken, ...options };
optionsWithToken = { pageToken: nextToken, ...options };
} else {
optionsWithToken = options;
}
const trials = await requestWithRetry({
json: true,
Expand All @@ -331,7 +334,7 @@ const upload = async ({ conn, maxRecords, days }) => {
pageSize: 1000,
'query.cond': 'cancer',
sort: 'LastUpdatePostDate',
...options,
...optionsWithToken,
},
uri: BASE_URL,
});
Expand Down

0 comments on commit 27511ed

Please sign in to comment.