Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Zhang (张涛) committed May 7, 2024
1 parent cc027fa commit b68c26b
Show file tree
Hide file tree
Showing 13 changed files with 299 additions and 61 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"devDependencies": {
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"husky": "^9.0.11"
"husky": "^9.0.11",
"@prisma/client": "5.8.1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
-- CreateTable
CREATE TABLE "user" (
"id" INTEGER NOT NULL,
"username" TEXT NOT NULL,
"password" TEXT NOT NULL,
"nickname" TEXT NOT NULL,
"avatar" TEXT NOT NULL,
"refresh_token" TEXT NOT NULL,
"access_token" TEXT NOT NULL,
"email" TEXT NOT NULL,
"favor" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "user_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Git" (
"id" TEXT NOT NULL,
"userID" TEXT NOT NULL,
"provider" TEXT NOT NULL,
"providerAccountId" TEXT NOT NULL,
"providerRefreshToken" TEXT NOT NULL,
"providerAccessToken" TEXT NOT NULL,
"providerScope" TEXT NOT NULL,
"loggedIn" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "Git_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "GitProvider" (
"id" TEXT NOT NULL,
"url" TEXT NOT NULL,
"clientID" TEXT NOT NULL,
"clientSecret" TEXT NOT NULL,
"type" TEXT NOT NULL,
"name" TEXT NOT NULL,
"disabled" BOOLEAN NOT NULL,

CONSTRAINT "GitProvider_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "coverage" (
"id" TEXT NOT NULL,
"key" TEXT NOT NULL,
"sha" TEXT NOT NULL,
"branch" TEXT NOT NULL,
"compare_target" TEXT NOT NULL,
"provider" TEXT NOT NULL,
"project_id" TEXT NOT NULL,
"instrument_cwd" TEXT NOT NULL,
"reporter" TEXT NOT NULL,
"report_id" TEXT NOT NULL,
"cov_type" TEXT NOT NULL,
"relation_id" JSONB NOT NULL,
"summary" JSONB NOT NULL,
"tag" JSONB NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "coverage_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "coveragedata" (
"id" TEXT NOT NULL,
"compresseddata" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "coveragedata_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "project" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"path_with_namespace" TEXT NOT NULL,
"description" TEXT NOT NULL,
"bu" TEXT NOT NULL,
"tag" TEXT NOT NULL,
"coverage" TEXT NOT NULL,
"default_branch" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "project_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "codechange" (
"id" TEXT NOT NULL,
"project_id" TEXT NOT NULL,
"compare_target" TEXT NOT NULL,
"sha" TEXT NOT NULL,
"path" TEXT NOT NULL,
"additions" INTEGER[],
"deletions" INTEGER[],
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "codechange_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "distributedlock" (
"lockName" TEXT NOT NULL,
"isLocked" BOOLEAN NOT NULL DEFAULT false,
"lockTimestamp" TIMESTAMP(3),
"lockExpiration" TIMESTAMP(3),

CONSTRAINT "distributedlock_pkey" PRIMARY KEY ("lockName")
);
3 changes: 3 additions & 0 deletions packages/canyon-backend/prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
5 changes: 2 additions & 3 deletions packages/canyon-backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ model Git {
}

model GitProvider {
id String @id
id String @id
url String
clientID String
clientSecret String
type String
name String
disabled Boolean
}

model Coverage {
Expand All @@ -55,7 +56,6 @@ model Coverage {
reporter String
reportID String @map("report_id") // 未来聚合的一句,区分case
covType String @map("cov_type") // 普通类型,默认normal
rule String // 规则
relationID Json @map("relation_id") // 关联ID,八位,{'0':'xxx','1':'xxx}
summary Json
tag Json // 存点额外的信息
Expand Down Expand Up @@ -83,7 +83,6 @@ model Project {
coverage String
defaultBranch String @map("default_branch")
createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(3)
rules Json
@@map("project")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ export class ConsumerCoverageService {
const newAgg = await this.prisma.coverage.create({
data: {
covType: covType,
rule: 'auto',
relationID: '',
summary: getSummaryByPath(
'~',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class CoverageClientService {
reporter: currentUser,
reportID: coverageReport.reportID,
covType: 'normal',
rule: 'auto', //没有就是手工
// rule: 'auto', //没有就是手工
summary: {},
tag: coverageReport.tags || {},
relationID: '',
Expand All @@ -111,7 +111,7 @@ export class CoverageClientService {
projectID: cov.projectID,
reportID: cov.reportID,
covType: 'normal',
rule: cov.rule,
// rule: cov.rule,
tag: JSON.stringify(cov.tag),
createdAt: new Date(),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/canyon-backend/src/project/project.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class ProjectResolver {
args.tag,
args.coverage,
args.defaultBranch,
args.rules,
// args.rules,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ export class GetProjectRecordsService {
});
const commits = await getCommits(
{
projectID,
projectID: projectID.split('-')[1],
commitShas: coverages.map((item) => item.sha),
},
'accessToken',
);

console.log(projectID.split('-')[1],'commits')

const rows = [];

const csList = await Promise.all(
Expand Down
15 changes: 3 additions & 12 deletions packages/canyon-backend/src/project/services/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Injectable } from '@nestjs/common';
import { PrismaService } from '../../prisma/prisma.service';
import { Project } from '../project.model';
import { getProjectByID } from 'src/adapter/gitlab.adapter';
import { projectRules } from '../project.zod';

// import { getProjectByID } from '../adapter/gitlab.adapter';
function parseGitLabUrl(gitLabUrl) {
Expand Down Expand Up @@ -51,14 +50,10 @@ export class ProjectService {
}

async createProject(user, projectID) {
const { accessToken } = await this.prisma.user.findFirst({
where: {
id: user.id,
},
});
// console.log(projectID.split('-'))
const { path_with_namespace, description, name, bu } = await getProjectByID(
projectID,
accessToken,
projectID.split('-')[1],
'accessToken',
);
return this.prisma.project.create({
data: {
Expand All @@ -70,7 +65,6 @@ export class ProjectService {
coverage: '',
tag: '',
defaultBranch: '-',
rules: {},
},
});
}
Expand All @@ -90,7 +84,6 @@ export class ProjectService {
tag,
coverage,
defaultBranch,
rules,
) {
function removeEmptyValues(obj) {
for (const key in obj) {
Expand All @@ -113,7 +106,6 @@ export class ProjectService {
tag: tag,
coverage: coverage,
defaultBranch: defaultBranch,
rules: rules,
}),
});
}
Expand Down Expand Up @@ -144,7 +136,6 @@ export class ProjectService {
coverage,
tag,
defaultBranch,
rules,
}) => {
return {
id,
Expand Down
1 change: 1 addition & 0 deletions packages/canyon-platform/src/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ declare global {
const Card: typeof import('antd')['Card']
const Divider: typeof import('antd')['Divider']
const Drawer: typeof import('antd')['Drawer']
const Flex: typeof import('antd')['Flex']
const FloatButton: typeof import('antd')['FloatButton']
const Form: typeof import('antd')['Form']
const Input: typeof import('antd')['Input']
Expand Down
6 changes: 4 additions & 2 deletions packages/canyon-platform/src/layouts/genBreadcrumbItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export function genBreadcrumbItems(pathname: string) {
{
title: <span className={'cursor-pointer'}>{t('projects.overview')}</span>,
onClick() {
const regex = /\/projects\/(\d+)\//;
const regex = /\/projects\/(.+?)\//;
// const regex = /\/projects\/(\d+)\//;
const match = pathname.match(regex);
if (match) {
const projectId = match[1];
Expand All @@ -58,7 +59,8 @@ export function genBreadcrumbItems(pathname: string) {
{
title: <span className={'cursor-pointer'}>{t('projects.overview')}</span>,
onClick() {
const regex = /\/projects\/(\d+)\//;
const regex = /\/projects\/(.+?)\//;
// const regex = /\/projects\/(\d+)\//;
const match = pathname.match(regex);
if (match) {
const projectId = match[1];
Expand Down
51 changes: 50 additions & 1 deletion packages/canyon-platform/src/pages/index/projects/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,56 @@ const ProjectOverviewPage = () => {
默认分支: {projectByIdData?.getProjectByID.defaultBranch}
</Text>
</div>
<div></div>
<div className={'flex pt-2 items-center'}>
<span className={'mr-2'}>标签: </span>
<Flex gap="4px 0" wrap>
<Tag bordered={false} color="processing">
processing
</Tag>
<Tag bordered={false} color="success">
success
</Tag>
<Tag bordered={false} color="error">
error
</Tag>
<Tag bordered={false} color="warning">
warning
</Tag>
<Tag bordered={false} color="magenta">
magenta
</Tag>
<Tag bordered={false} color="red">
red
</Tag>
<Tag bordered={false} color="volcano">
volcano
</Tag>
<Tag bordered={false} color="orange">
orange
</Tag>
<Tag bordered={false} color="gold">
gold
</Tag>
<Tag bordered={false} color="lime">
lime
</Tag>
<Tag bordered={false} color="green">
green
</Tag>
<Tag bordered={false} color="cyan">
cyan
</Tag>
<Tag bordered={false} color="blue">
blue
</Tag>
<Tag bordered={false} color="geekblue">
geekblue
</Tag>
<Tag bordered={false} color="purple">
purple
</Tag>
</Flex>
</div>
</div>

<Text type={'secondary'} className={'block mb-3'}>
Expand Down
Loading

0 comments on commit b68c26b

Please sign in to comment.