Skip to content

Commit

Permalink
feat: rerun tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Oct 13, 2023
1 parent fccf129 commit 5816a5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ git config user.name "Allen Zhang" && git config user.email "[email protected]"
1.需要一个覆盖率的 react 组件,主要功能展示覆盖率的数据,以及覆盖率的趋势图,增量覆盖率
2.tree 树形组件,文件夹的展开和收起
3.另存为,可以新建文件夹


==

1.新增行覆盖率,必须指定好basecommitsha
2.触发聚合的时候拉去 basecommitsha和headcommitsha的覆盖率数据,有的化才落库,方便下次查询
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { CoverageDataDocument } from '../../coverage/schema/coverage-data.schema
import { compressedData, decompressedData } from '../../utils/zstd';
import CanyonUtil from 'canyon-util';
import getNewLinesOfFileFromGitlabByRepoIDAndCommitSha from '../helpers';
// import * as process from 'process';
import { Cron, Interval } from '@nestjs/schedule';
import { calculateAllNewLineCoverageForProject } from '../../utils/coverage';

Expand Down Expand Up @@ -264,7 +263,7 @@ export class CoverageAggTaskService {
}

// 定时任务,每隔一段时间查询一下还在 running 的任务,并且重置一下状态
@Interval(1 * 60 * 1000)
@Interval(1 * 60 * 1000 * (Math.random() + 1)) //添加随机数,防止分布式服务同时执行
async rerun() {
const tasks = await this.prisma.task.findMany({
where: {
Expand All @@ -289,9 +288,9 @@ export class CoverageAggTaskService {
}
}

// 每过一天清理一下coverage集合,删除超过一周未聚合的数据
// 每过一天清理一下coverage集合,删除超过一周的normal数据
@Cron('30 2 * * *') // 每天凌晨2点半执行
async shanchu123() {
async cleaningUpOutdatedData() {
const coverageDeleteManyRes = await this.prisma.coverage.deleteMany({
where: {
cov_type: 'normal',
Expand Down

0 comments on commit 5816a5c

Please sign in to comment.