Skip to content

Commit

Permalink
chore: repo overall update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Nov 20, 2024
1 parent ca3beaf commit 63b846c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 137 deletions.
137 changes: 1 addition & 136 deletions packages/canyon-collect/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,144 +1,9 @@
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import { PrismaService } from './prisma/prisma.service';
// import { zstdDecompressedData } from './utils/zstd2';
// import { coverageObj } from './apps/collect/models/coverage.model';
// import { IstanbulHitMapSchema, IstanbulMapMapSchema } from './zod/istanbul.zod';
// import { removeStartEndNull } from './utils/coverage';
// import { compressedData } from './utils/zstd';
// import { genSummaryMapByCoverageMap, mergeCoverageMap } from 'canyon-data';
// import fs from 'node:fs';

@Controller()
export class AppController {
constructor(
private readonly appService: AppService,
private readonly prisma: PrismaService,
) {
// (async () => {
// const queueDataToBeConsumed = {
// projectID: 'tripgl-61889-auto',
// sha: 'c35964171aa900bcb99fcda97d91c31414aea6ab',
// };
// const co = await this.prisma.coverageOld
// .findFirst({
// where: {
// ...queueDataToBeConsumed,
// covType: 'all',
// },
// })
// .then((r) => {
// // const map = r.hit;
// return zstdDecompressedData(r.hit);
// });
//
// const hit1 = JSON.parse(co);
//
// const coverageMaps = await this.prisma.coverageMap.findMany({
// where: {
// sha: queueDataToBeConsumed.sha,
// projectID: queueDataToBeConsumed.projectID,
// },
// });
//
// const coverageJsonMaps = await Promise.all(
// coverageMaps.map((coverageMap) => {
// return zstdDecompressedData(coverageMap.map).then((map) => {
// return {
// ...coverageMap,
// ...JSON.parse(map),
// };
// });
// }),
// );
// const obj = {};
// coverageJsonMaps.forEach((item) => {
// if (hit1[item.path]) {
// const o = {
// ...hit1[item.path],
// ...item,
// path: item.path,
// };
// obj[item.path] = {
// path: o.path,
// b: o.b || {},
// f: o.f || {},
// s: o.s || {},
// branchMap: o.branchMap || {},
// fnMap: o.fnMap || {},
// statementMap: o.statementMap || {},
// };
// }
// });
//
// // const { sha, projectID } = coverageMaps;
//
// const branch = 'master';
// const sha = 'c35964171aa900bcb99fcda97d91c31414aea6ab';
// const projectID = 'tripgl-61889-auto';
//
// // const compressedFormatCoverageStr = await
//
// const formatCoverageMap = IstanbulMapMapSchema.parse(
// removeStartEndNull(obj),
// );
//
// const formatCoverageStr = JSON.stringify(formatCoverageMap);
// const compressedFormatCoverageStr =
// await compressedData(formatCoverageStr);
//
// // hit
// const formatCoverageHit = IstanbulHitMapSchema.parse(obj);
//
// // console.log(coverageMapCount111, formatCoverage);
//
// // ********* 合并
// // const mergeCoveHit = mergeCoverageMap(coverageDbHit, formatCoverageHit);
// // *********
//
// // update
// // mergeCoveHit
// const hitBuffer = await compressedData(JSON.stringify(formatCoverageHit));
//
// // 直接存summary,数组形式
// const summary = Object.entries(genSummaryMapByCoverageMap(obj, [])).map(
// ([key, value]) => ({
// path: key,
// ...value,
// }),
// );
//
// const summaryBuffer = await compressedData(JSON.stringify(summary));
//
// const rs1 = await this.prisma.coverage.create({
// data: {
// ...coverageObj,
// branch: branch || '-',
// compareTarget: sha,
// provider: 'github',
// buildProvider: 'github',
// buildID: '',
// projectID: projectID,
// sha: sha,
// reporter: 'canyon',
// reportID: sha,
// covType: 'all', //map都是all
// statementsTotal: 0,
// statementsCovered: 0,
// //空bytes
// summary: summaryBuffer,
// hit: hitBuffer,
// map: compressedFormatCoverageStr,
// instrumentCwd: '',
// },
// });
//
// console.log(rs1);
//
// // console.log(obj)
// // fs.writeFileSync('./coverage.json', JSON.stringify(obj));
// })();
}
constructor(private readonly appService: AppService) {}

@Get()
getHello(): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export class CoverageClientService {

const coverageDbMap = await decompressedData(coverageDb.map);

const coverageDbHit = await decompressedData(coverageDb.hit);
// 初始的hit是空的
const coverageDbHit =
coverageDb.hit.length > 0 ? await decompressedData(coverageDb.hit) : {};
// 流程需要改一下
// 1. 不反map
// 2. 在消费的时候再反map
Expand Down

0 comments on commit 63b846c

Please sign in to comment.