Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Jun 3, 2024
1 parent 1e7ad72 commit 57372dc
Showing 1 changed file with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
import { Injectable } from '@nestjs/common';
import { PrismaService } from '../../prisma/prisma.service';
import { within30days } from '../../utils/utils';
import { Prisma } from '@prisma/client';
import { removeNullKeys, within30days } from '../../utils/utils';
import * as dayjs from 'dayjs';
@Injectable()
export class GetProjectsService {
private coverages: any[] = [];
constructor(private readonly prisma: PrismaService) {
// 20秒刷新一次
setInterval(async () => {
this.coverages = await this.prisma.coverage.findMany({
where: {
covType: 'all',
},
select: {
projectID: true,
// project: true,
sha: true,
// branch: true,
// report: true,
createdAt: true,
updatedAt: true,
summary: true,
},
});
}, 1000 * 20);
}
constructor(private readonly prisma: PrismaService) {}
async invoke(
userID,
current,
Expand Down Expand Up @@ -71,8 +52,7 @@ export class GetProjectsService {
in: lang,
};
}
const cov = this.coverages;
const pro = this.prisma.project.findMany({
const pro = await this.prisma.project.findMany({
where: whereCondition,
select: {
id: true,
Expand All @@ -82,6 +62,25 @@ export class GetProjectsService {
language: true,
},
});
const cov = await this.prisma.coverage.findMany({
where: {
covType: 'all',
projectID: {
in: pro.map(({ id }) => id),
},
},
select: {
projectID: true,
// project: true,
sha: true,
// branch: true,
// report: true,
createdAt: true,
updatedAt: true,
summary: true,
},
});

const rows = await Promise.all([cov, pro]).then((res) => {
const reslut = [];
const pros = res[1];
Expand Down

0 comments on commit 57372dc

Please sign in to comment.