refactor: Add CopilotEventStatus column to CopilotEvent model

This commit adds a new column, CopilotEventStatus, to the CopilotEvent model in the CopilotEvent.ts file. The CopilotEventStatus column represents the status of a Copilot event that was triggered for a file in the code repository. This enhancement improves the functionality and flexibility of the CopilotEvent model.
This commit is contained in:
Simon Larsen 2024-06-13 14:39:26 +01:00
parent c15b8bb951
commit 170b79e4cf
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
4 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,6 @@
enum CopilotEventStatus {
PR_CREATED = 'Pull Request Created', // PR created and waiting for review
NO_ACTION_REQUIRED = 'No Action Required', // No PR needed. All is good.
}
export default CopilotEventStatus;

View File

@ -0,0 +1,23 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class MigrationName1718285877004 implements MigrationInterface {
public name = 'MigrationName1718285877004';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "CopilotEvent" ADD "pullRequestId" character varying`
);
await queryRunner.query(
`ALTER TABLE "CopilotEvent" ADD "copilotEventStatus" character varying NOT NULL`
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "CopilotEvent" DROP COLUMN "copilotEventStatus"`
);
await queryRunner.query(
`ALTER TABLE "CopilotEvent" DROP COLUMN "pullRequestId"`
);
}
}

View File

@ -11,6 +11,7 @@ import { MigrationName1718124277321 } from './1718124277321-MigrationName';
import { MigrationName1718126316684 } from './1718126316684-MigrationName';
import { MigrationName1718188920011 } from './1718188920011-MigrationName';
import { MigrationName1718203144945 } from './1718203144945-MigrationName';
import { MigrationName1718285877004 } from './1718285877004-MigrationName';
export default [
InitialMigration,
@ -26,4 +27,5 @@ export default [
MigrationName1718126316684,
MigrationName1718188920011,
MigrationName1718203144945,
MigrationName1718285877004,
];

View File

@ -5,6 +5,7 @@ import ServiceRepository from './ServiceRepository';
import User from './User';
import BaseModel from 'Common/Models/BaseModel';
import Route from 'Common/Types/API/Route';
import CopilotEventStatus from 'Common/Types/Copilot/CopilotEventStatus';
import CopilotEventType from 'Common/Types/Copilot/CopilotEventType';
import ColumnAccessControl from 'Common/Types/Database/AccessControl/ColumnAccessControl';
import TableAccessControl from 'Common/Types/Database/AccessControl/TableAccessControl';
@ -293,6 +294,7 @@ export default class CopilotEvent extends BaseModel {
@TableColumn({
type: TableColumnType.LongText,
title: 'File Path in Code Repository',
required: true,
description:
'File Path in Code Repository where this event was triggered',
})
@ -461,4 +463,50 @@ export default class CopilotEvent extends BaseModel {
transformer: ObjectID.getDatabaseTransformer(),
})
public serviceRepositoryId?: ObjectID = undefined;
@ColumnAccessControl({
create: [],
read: [
Permission.ProjectOwner,
Permission.ProjectAdmin,
Permission.ProjectMember,
Permission.ReadCopilotEvent,
],
update: [],
})
@TableColumn({
type: TableColumnType.ShortText,
required: false,
isDefaultValueColumn: false,
title: 'Pull Request ID',
description:
'ID of Pull Request in the repository where this event was executed and then PR was created.',
})
@Column({
type: ColumnType.ShortText,
nullable: true,
})
public pullRequestId?: string = undefined;
@ColumnAccessControl({
create: [],
read: [
Permission.ProjectOwner,
Permission.ProjectAdmin,
Permission.ProjectMember,
Permission.ReadCopilotEvent,
],
update: [],
})
@TableColumn({
type: TableColumnType.ShortText,
title: 'Copilot Event Status',
description:
'Status of Copilot Event that was triggered for this file in Code Repository',
})
@Column({
type: ColumnType.ShortText,
nullable: false,
})
public copilotEventStatus?: CopilotEventStatus = undefined;
}