-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #260 from DestinyItemManager/loadout-share-migrate
User import
- Loading branch information
Showing
9 changed files
with
112 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { chunk } from 'es-toolkit'; | ||
import { readTransaction } from '../../db/index.js'; | ||
import { getUsersToMigrate } from '../../db/migration-state-queries.js'; | ||
import { delay } from '../../utils.js'; | ||
import { migrateUser } from '../migrator/user.js'; | ||
|
||
while (true) { | ||
try { | ||
const bungieMembershipIds = await readTransaction(async (client) => getUsersToMigrate(client)); | ||
if (bungieMembershipIds.length === 0) { | ||
console.log('No users to migrate'); | ||
break; | ||
} | ||
for (const idChunk of chunk(bungieMembershipIds, 10)) { | ||
await Promise.all( | ||
idChunk.map(async (bungieMembershipId) => { | ||
try { | ||
await migrateUser(bungieMembershipId); | ||
console.log(`Migrated user ${bungieMembershipId}`); | ||
} catch (e) { | ||
if (e instanceof Error) { | ||
console.error(`Error migrating user ${bungieMembershipId}: ${e}`); | ||
} | ||
} | ||
}), | ||
); | ||
} | ||
} catch (e) { | ||
if (e instanceof Error) { | ||
console.error(`Error getting users to migrate: ${e}`); | ||
} | ||
await delay(1000); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.