mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
fix too many requests
This commit is contained in:
parent
11cac54ba0
commit
2fc271d7aa
1 changed files with 9 additions and 8 deletions
|
@ -39,14 +39,15 @@ function getTag(tagId) {
|
||||||
|
|
||||||
/* Fetches lots of tags in batches and stores them locally */
|
/* Fetches lots of tags in batches and stores them locally */
|
||||||
function fetchAndPersistTags(tagIds) {
|
function fetchAndPersistTags(tagIds) {
|
||||||
const chunk = 40;
|
if (!tagIds.length) return;
|
||||||
for (let i = 0; i < tagIds.length; i += chunk) {
|
|
||||||
const ids = tagIds.slice(i, i + chunk);
|
|
||||||
|
|
||||||
fetch(`/tags/fetch?ids[]=${ids.join('&ids[]=')}`)
|
const ids = tagIds.slice(0, 40);
|
||||||
.then(response => response.json())
|
const remaining = tagIds.slice(41);
|
||||||
.then(data => data.tags.forEach(tag => persistTag(tag)));
|
|
||||||
}
|
fetch(`/tags/fetch?ids[]=${ids.join('&ids[]=')}`)
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => data.tags.forEach(tag => persistTag(tag)))
|
||||||
|
.then(() => fetchAndPersistTags(remaining));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Figure out which tags in the list we don't know about */
|
/* Figure out which tags in the list we don't know about */
|
||||||
|
@ -109,4 +110,4 @@ function BooruOnRails() {
|
||||||
|
|
||||||
window.booru = new BooruOnRails();
|
window.booru = new BooruOnRails();
|
||||||
|
|
||||||
export { getTag, loadBooruData };
|
export { getTag, loadBooruData };
|
||||||
|
|
Loading…
Reference in a new issue