Look up PubMed IDs in batches of 200

https://forums.zotero.org/discussion/comment/440245/#Comment_440245
This commit is contained in:
Dan Stillman 2023-08-05 00:01:39 -04:00
parent fcc68d6d80
commit af91173734

View file

@ -81,6 +81,23 @@ var Zotero_Lookup = new function () {
toggleProgress(true); toggleProgress(true);
// Group PubMed IDs into batches of 200
//
// Up to 10,000 ids can apparently be passed in a single request, but 200 is the recommended
// limit for GET, which we currently use, and passing batches of 200 seems...fine.
//
// https://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.id
if (identifiers.length && identifiers[0].PMID) {
let chunkSize = 200;
let newIdentifiers = [];
for (let i = 0; i < identifiers.length; i += chunkSize) {
newIdentifiers.push({
PMID: identifiers.slice(i, i + chunkSize).map(x => x.PMID)
});
}
identifiers = newIdentifiers;
}
let newItems = []; let newItems = [];
for (let identifier of identifiers) { for (let identifier of identifiers) {
let translate = new Zotero.Translate.Search(); let translate = new Zotero.Translate.Search();