Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/routes/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { importSearches } from '../stately/searches-queries.js';
import { convertToStatelyItem } from '../stately/settings-queries.js';
import { batches } from '../stately/stately-utils.js';
import { importTriumphs } from '../stately/triumphs-queries.js';
import { badRequest, subtractObject } from '../utils.js';
import { badRequest, delay, subtractObject } from '../utils.js';
import { deleteAllData } from './delete-all-data.js';

export const importHandler = asyncHandler(async (req, res) => {
Expand Down Expand Up @@ -265,6 +265,7 @@ export async function statelyImport(
// OK now put them in as fast as we can
for (const batch of batches(items)) {
await client.putBatch(...batch);
await delay(100); // give it some time to flush
}

return numTriumphs;
Expand Down
3 changes: 2 additions & 1 deletion api/stately/bulk-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ExportResponse } from '../shapes/export.js';
import { DestinyVersion } from '../shapes/general.js';
import { ProfileResponse } from '../shapes/profile.js';
import { defaultSettings } from '../shapes/settings.js';
import { subtractObject } from '../utils.js';
import { delay, subtractObject } from '../utils.js';
import { client } from './client.js';
import { AnyItem } from './generated/index.js';
import { convertItemAnnotation, keyFor as tagKeyFor } from './item-annotations-queries.js';
Expand Down Expand Up @@ -76,6 +76,7 @@ async function deleteAllDataForProfile(
// Then delete them all. We're not in a transaction!
for (const batch of batches(keys)) {
await client.del(...batch);
await delay(100); // give it some time to flush
}
return response;
}
Expand Down
4 changes: 4 additions & 0 deletions api/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,7 @@ export function subtractObject<T extends object>(obj: Partial<T>, defaults: T):
}
return result;
}

export function delay(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}