Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Zhang (ๅผ ๆถ›) committed Apr 9, 2024
1 parent 8f6faca commit 665cc17
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/canyon-backend/src/coverage/coverage.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { CoverageDataAdapterService } from './services/coverage-data-adapter.service';
import { ConsumerCoverageService } from './services/consumer-coverage.service';
import { PullChangeCodeAndInsertDbService } from './services/pull-change-code-and-insert-db.service';
import { CoverageLog, CoverageLogSchema } from './schemas/coverage-log.schema';

@Module({
imports: [
Expand All @@ -22,6 +23,11 @@ import { PullChangeCodeAndInsertDbService } from './services/pull-change-code-an
schema: CoverageDataSchema,
collection: 'canyon_coverage_data',
},
{
name: CoverageLog.name,
schema: CoverageLogSchema,
collection: 'canyon_coverage_log',
},
]),
],
controllers: [CoverageController],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
// ๅฎšไน‰ 'ant' ็ฑปๅž‹
// ๅฎšไน‰ antType ็ฑปๅž‹
// type CoverageType = {
// [key: string]: object;
// };

@Schema()
export class CoverageLog {
@Prop()
coverageID: string;

@Prop({ type: Object })
coverage: any;
}

export const CoverageLogSchema = SchemaFactory.createForClass(CoverageLog);
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { CoverageClientDto } from '../dto/coverage-client.dto';
import { formatReportObject } from '../../utils/coverage';
import { Coverage } from '@prisma/client';
import { pushQueue } from '../../queues/coverage';
import { InjectModel } from '@nestjs/mongoose';
// import { CoverageData } from '../schemas/coverage-data.schema';
import { Model } from 'mongoose';
import { CoverageLog } from '../schemas/coverage-log.schema';
/**
* ไธŠไผ ่ฆ†็›–็Ž‡๏ผŒๅๅˆ†้‡่ฆ็š„ๆœๅŠก
*/
Expand All @@ -26,7 +30,11 @@ function checkUserID(id) {

@Injectable()
export class CoverageClientService {
constructor(private readonly prisma: PrismaService) {}
constructor(
private readonly prisma: PrismaService,
@InjectModel(CoverageLog.name)
private coverageLogModel: Model<CoverageLog>,
) {}

async invoke(currentUser, coverageClientDto: CoverageClientDto) {
if (coverageClientDto.projectID === '98620') {
Expand Down Expand Up @@ -100,7 +108,13 @@ export class CoverageClientService {
//ๅŽๅŠ ็š„
coverage: coverageReport.coverage,
};

await this.coverageLogModel.create({
coverageID: cov.id,
coverage: {
...cov,
coverage: 1,
},
});
pushQueue(cov);
return {
msg: 'ok',
Expand Down

0 comments on commit 665cc17

Please sign in to comment.