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 19, 2024
1 parent 5a2c672 commit 4b7bcd3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Body, Controller, Get, Post, UseInterceptors } from '@nestjs/common';
import { Body, Controller, Post, UseInterceptors } from '@nestjs/common';
import { PrismaService } from '../../prisma/prisma.service';
import { CoverageClientService } from './services/coverage-client.service';
import { CoverageClientDto } from './dto/coverage-client.dto';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export class CoverageMapClientDto {
@IsNotEmpty({ message: 'sha 不能为空' })
sha: string;

// @IsString()
// @MinLength(1, { message: "branch长度最小为1" })
// @IsOptional({ message: "branch 可以为空" })
// branch: string;
@IsString()
@MinLength(1, { message: 'branch长度最小为1' })
@IsOptional({ message: 'branch 可以为空' })
branch: string;

// @IsString()
// @MinLength(1, { message: "buildID长度最小为1" })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import {
HttpException,
Injectable,
UnauthorizedException,
} from '@nestjs/common';
import { HttpException, Injectable } from '@nestjs/common';
import { PrismaService } from '../../../prisma/prisma.service';
import { IstanbulHitMapSchema } from '../../../zod/istanbul.zod';
import { compressedData } from '../../../utils/zstd';
import {
formatReportObject,
regularData,
resetCoverageData,
} from '../../../utils/coverage';
import { formatReportObject, regularData } from '../../../utils/coverage';

@Injectable()
export class CoverageClientService {
constructor(private readonly prisma: PrismaService) {}
async invoke({ sha, projectID, coverage, instrumentCwd, branch, reportID }) {
async invoke({ sha, projectID, coverage, instrumentCwd }) {
// 1. 检查是否上传map
const coverageMapCount = await this.prisma.coverage.count({
where: {
Expand Down Expand Up @@ -47,6 +39,9 @@ export class CoverageClientService {
// const size = new TextEncoder().encode(formatCoverageStr).length;
const compressedFormatCoverageStr = await compressedData(formatCoverageStr);

// 先不考虑分布式,直接存储
// this.prisma.coverage.upsert()

return this.prisma.coverage.updateMany({
where: {
projectID: projectID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
// IstanbulHitMapSchema,
IstanbulMapMapSchema,
} from '../../../zod/istanbul.zod';
import { compressedData, decompressedData } from '../../../utils/zstd';
import { compressedData } from '../../../utils/zstd';
import {
formatReportObject,
regularData,
Expand All @@ -15,7 +15,7 @@ import { coverageObj } from '../models/coverage.model';
@Injectable()
export class CoverageMapClientService {
constructor(private readonly prisma: PrismaService) {}
async invoke({ sha, projectID, coverage, instrumentCwd, branch, reportID }) {
async invoke({ sha, projectID, coverage, instrumentCwd, branch }) {
// const { sha, projectID } = invoke;

const coverageObject =
Expand Down Expand Up @@ -54,12 +54,13 @@ export class CoverageMapClientService {
projectID: projectID,
sha: sha,
reporter: 'canyon',
reportID: reportID || sha,
reportID: sha,
covType: 'all', //map都是all
statementsTotal: 0,
statementsCovered: 0,
summary: '',
hit: '',
//空bytes
summary: Buffer.from([]),
hit: Buffer.from([]),
map: compressedFormatCoverageStr,
},
})
Expand Down

0 comments on commit 4b7bcd3

Please sign in to comment.