import { forEachAsync, getAxiosClient } from '../../utils' import { DBClient } from '../../singletons' import { InitiaClient } from '../../InitiaClient' async function startCheck(concurrency) { const accountsRaw = await DBClient.instance.randomTask2.findMany({ where: { finish: 1, }, take: 40000, }) await forEachAsync(accountsRaw, concurrency, async (account, index) => { console.log( `${index}/${accountsRaw.length}: processing ${account.address},account id: ${account.id}`, ) try { const axios = getAxiosClient(true) const res = await axios.get( `https://xp-api.initiation-1.initia.xyz/xp/weekly/${account.address}/3`, ) console.log(res.data) const finishedTasks = res.data.finishedTasks if (finishedTasks.length === 6) { await DBClient.instance.randomTask2.update({ where: { id: account.id }, data: { finish: 2 }, }) } } catch (e) { console.log(e.message) return } }) } startCheck(50)