From 910455e5344ab11ef71a0337d6e4cbfdbb1ffc05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Allen=20Zhang=20=28=E5=BC=A0=E6=B6=9B=29?= Date: Sun, 14 Jul 2024 12:13:26 +0800 Subject: [PATCH] feat: update --- .../canyon-backend/src/task/syns.service.ts | 50 +++++++++++-------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/packages/canyon-backend/src/task/syns.service.ts b/packages/canyon-backend/src/task/syns.service.ts index 926b790f..b2bb4fb7 100644 --- a/packages/canyon-backend/src/task/syns.service.ts +++ b/packages/canyon-backend/src/task/syns.service.ts @@ -76,31 +76,41 @@ export class SynsService { const fileMapTasks = Object.entries(coverage).map( async (coverageEntries) => { const [path, fileCoverage]: any = coverageEntries; - await this.prisma.covMapTest - .create({ - data: { - id: `__${projectID}__${sha}__${path}__`, - mapJsonStr: JSON.stringify({ - fnMap: fileCoverage.fnMap, - statementMap: fileCoverage.statementMap, - branchMap: fileCoverage.branchMap, - }), - projectID:projectID, - sha:sha, - path, - }, - }) - .then((res) => { - return res; - }) - .catch(() => { - return true; - }); + }, ); const time2 = new Date().getTime(); await Promise.all(fileMapTasks); + + const rows = Object.entries(coverage).map((coverageEntries)=>{ + const [path, fileCoverage]: any = coverageEntries; + return { + id: `__${projectID}__${sha}__${path}__`, + mapJsonStr: JSON.stringify({ + fnMap: fileCoverage.fnMap, + statementMap: fileCoverage.statementMap, + branchMap: fileCoverage.branchMap, + }), + projectID:projectID, + sha:sha, + path, + } + }) + + + await this.prisma.covMapTest + .createMany({ + data: rows, + skipDuplicates: true, + }) + .then((res) => { + return res; + }) + .catch(() => { + return true; + }); + console.log('fileMapTasks', new Date().getTime() - time2);