Skip to content

Commit

Permalink
perf: init4811
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu authored and FinleyGe committed Oct 12, 2024
1 parent 878932a commit 5090697
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions projects/app/src/pages/api/admin/initv4811.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,30 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)

async function createGroup(teamId: string) {
try {
await MongoMemberGroupModel.create({
teamId: teamId,
name: DefaultGroupName
});
console.log(++success);
await MongoMemberGroupModel.updateOne(
{
teamId,
name: DefaultGroupName
},
{
$set: {
teamId: teamId,
name: DefaultGroupName
}
},
{
upsert: true
}
);
} catch (error) {
console.log(error);
await delay(500);
return createGroup(teamId);
}
}
for await (const team of teamList) {
await createGroup(team._id);
console.log(++success);
}

jsonRes(res, {
Expand Down

0 comments on commit 5090697

Please sign in to comment.