diff --git a/onecgiar-pr-server/src/api/result-qaed/entities/result-qaed-log.entity.ts b/onecgiar-pr-server/src/api/result-qaed/entities/result-qaed-log.entity.ts new file mode 100644 index 000000000..b560007d5 --- /dev/null +++ b/onecgiar-pr-server/src/api/result-qaed/entities/result-qaed-log.entity.ts @@ -0,0 +1,55 @@ +import { + Column, + Entity, + JoinColumn, + ManyToOne, + PrimaryGeneratedColumn, +} from 'typeorm'; +import { User } from '../../../auth/modules/user/entities/user.entity'; +import { Result } from '../../results/entities/result.entity'; + +@Entity('result_qaed_log') +export class ResultQaedLog { + @PrimaryGeneratedColumn({ + name: 'id', + type: 'bigint', + }) + id: number; + + @Column({ + name: 'result_id', + type: 'bigint', + }) + result_id: number; + + @Column({ + name: 'qaed_date', + type: 'date', + }) + qaed_date: Date; + + @Column({ + name: 'qaed_comments', + type: 'text', + nullable: true, + }) + qaed_comments: string; + + @Column({ + name: 'qaed_user', + type: 'bigint', + }) + qaed_user: number; + + @ManyToOne(() => Result, (r) => r.obj_result_qaed, { nullable: true }) + @JoinColumn({ + name: 'result_id', + }) + obj_result_id_qaed: Result; + + @ManyToOne(() => User, (u) => u.obj_qaed_user, { nullable: true }) + @JoinColumn({ + name: 'qaed_user', + }) + obj_qaed_user: User; +} diff --git a/onecgiar-pr-server/src/api/result-qaed/result-qaed.controller.spec.ts b/onecgiar-pr-server/src/api/result-qaed/result-qaed.controller.spec.ts new file mode 100644 index 000000000..f2eb52903 --- /dev/null +++ b/onecgiar-pr-server/src/api/result-qaed/result-qaed.controller.spec.ts @@ -0,0 +1,20 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { ResultQaedController } from './result-qaed.controller'; +import { ResultQaedService } from './result-qaed.service'; + +describe('ResultQaedController', () => { + let controller: ResultQaedController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [ResultQaedController], + providers: [ResultQaedService], + }).compile(); + + controller = module.get(ResultQaedController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/onecgiar-pr-server/src/api/result-qaed/result-qaed.controller.ts b/onecgiar-pr-server/src/api/result-qaed/result-qaed.controller.ts new file mode 100644 index 000000000..c6c566ed6 --- /dev/null +++ b/onecgiar-pr-server/src/api/result-qaed/result-qaed.controller.ts @@ -0,0 +1,7 @@ +import { Controller } from '@nestjs/common'; +import { ResultQaedService } from './result-qaed.service'; + +@Controller('result-qaed') +export class ResultQaedController { + constructor(private readonly resultQaedService: ResultQaedService) {} +} diff --git a/onecgiar-pr-server/src/api/result-qaed/result-qaed.module.ts b/onecgiar-pr-server/src/api/result-qaed/result-qaed.module.ts new file mode 100644 index 000000000..3fc28df09 --- /dev/null +++ b/onecgiar-pr-server/src/api/result-qaed/result-qaed.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { ResultQaedService } from './result-qaed.service'; +import { ResultQaedController } from './result-qaed.controller'; + +@Module({ + controllers: [ResultQaedController], + providers: [ResultQaedService], +}) +export class ResultQaedModule {} diff --git a/onecgiar-pr-server/src/api/result-qaed/result-qaed.service.spec.ts b/onecgiar-pr-server/src/api/result-qaed/result-qaed.service.spec.ts new file mode 100644 index 000000000..5fc66c660 --- /dev/null +++ b/onecgiar-pr-server/src/api/result-qaed/result-qaed.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { ResultQaedService } from './result-qaed.service'; + +describe('ResultQaedService', () => { + let service: ResultQaedService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [ResultQaedService], + }).compile(); + + service = module.get(ResultQaedService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/onecgiar-pr-server/src/api/result-qaed/result-qaed.service.ts b/onecgiar-pr-server/src/api/result-qaed/result-qaed.service.ts new file mode 100644 index 000000000..ff58f4418 --- /dev/null +++ b/onecgiar-pr-server/src/api/result-qaed/result-qaed.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from '@nestjs/common'; + +@Injectable() +export class ResultQaedService {} diff --git a/onecgiar-pr-server/src/api/results/entities/result.entity.ts b/onecgiar-pr-server/src/api/results/entities/result.entity.ts index 68ab94b5d..4956c905d 100644 --- a/onecgiar-pr-server/src/api/results/entities/result.entity.ts +++ b/onecgiar-pr-server/src/api/results/entities/result.entity.ts @@ -29,6 +29,7 @@ import { ResultsByInstitution } from '../results_by_institutions/entities/result import { ShareResultRequest } from '../share-result-request/entities/share-result-request.entity'; import { ResultsTocResult } from '../results-toc-results/entities/results-toc-result.entity'; import { Notification } from '../../notification/entities/notification.entity'; +import { ResultQaedLog } from '../../result-qaed/entities/result-qaed-log.entity'; @Entity() export class Result { @@ -351,34 +352,6 @@ export class Result { // helpers?? initiative_id!: number; - // *** QA tracking fields - @Column({ - name: 'qaed_date', - type: 'timestamp', - nullable: true, - }) - qaed_date: Date; - - @Column({ - name: 'qaed_comment', - type: 'text', - nullable: true, - }) - qaed_comment: string; - - @Column({ - name: 'qaed_user', - type: 'int', - nullable: true, - }) - qaed_user: number; - - @ManyToOne(() => User, (u) => u.obj_qaed_user, { nullable: true }) - @JoinColumn({ - name: 'qaed_user', - }) - obj_qaed_user: User; - @OneToMany(() => ResultsKnowledgeProduct, (rkp) => rkp.result_object) result_knowledge_product_array: ResultsKnowledgeProduct[]; @@ -420,4 +393,7 @@ export class Result { @OneToMany(() => Notification, (ra) => ra.obj_result) obj_result_notification: Notification[]; + + @OneToMany(() => ResultQaedLog, (ra) => ra.obj_result_id_qaed) + obj_result_qaed: Notification[]; } diff --git a/onecgiar-pr-server/src/app.module.ts b/onecgiar-pr-server/src/app.module.ts index 77483f66e..9296bf844 100644 --- a/onecgiar-pr-server/src/app.module.ts +++ b/onecgiar-pr-server/src/app.module.ts @@ -41,6 +41,7 @@ import { SharePointModule } from './shared/services/share-point/share-point.modu import { NotificationModule } from './api/notification/notification.module'; import { UserNotificationSettingsModule } from './api/user-notification-settings/user-notification-settings.module'; import { EmailNotificationManagementModule } from './shared/microservices/email-notification-management/email-notification-management.module'; +import { ResultQaedModule } from './api/result-qaed/result-qaed.module'; @Module({ imports: [ @@ -78,6 +79,7 @@ import { EmailNotificationManagementModule } from './shared/microservices/email- UserNotificationSettingsModule, EmailNotificationManagementModule, NotificationModule, + ResultQaedModule, ], controllers: [AppController], providers: [ diff --git a/onecgiar-pr-server/src/auth/modules/user/entities/user.entity.ts b/onecgiar-pr-server/src/auth/modules/user/entities/user.entity.ts index 895aa1cad..6365e5871 100644 --- a/onecgiar-pr-server/src/auth/modules/user/entities/user.entity.ts +++ b/onecgiar-pr-server/src/auth/modules/user/entities/user.entity.ts @@ -11,7 +11,7 @@ import { } from 'typeorm'; import { Notification } from '../../../../api/notification/entities/notification.entity'; import { UserNotificationSetting } from '../../../../api/user-notification-settings/entities/user-notification-settings.entity'; -import { Result } from '../../../../api/results/entities/result.entity'; +import { ResultQaedLog } from '../../../../api/result-qaed/entities/result-qaed-log.entity'; @Entity('users') @Index(['email'], { unique: true }) @@ -103,6 +103,6 @@ export class User { ) obj_emitter_user_notification: Notification[]; - @OneToMany(() => Result, (r) => r.obj_qaed_user) - obj_qaed_user: Result[]; + @OneToMany(() => ResultQaedLog, (r) => r.obj_qaed_user) + obj_qaed_user: ResultQaedLog[]; } diff --git a/onecgiar-pr-server/src/migrations/1731503453561-RemovedQATrackingFieldsFromResult.ts b/onecgiar-pr-server/src/migrations/1731503453561-RemovedQATrackingFieldsFromResult.ts new file mode 100644 index 000000000..79b81c3bd --- /dev/null +++ b/onecgiar-pr-server/src/migrations/1731503453561-RemovedQATrackingFieldsFromResult.ts @@ -0,0 +1,33 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class RemovedQATrackingFieldsFromResult1731503453561 + implements MigrationInterface +{ + name = 'RemovedQATrackingFieldsFromResult1731503453561'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE \`result\` DROP FOREIGN KEY \`FK_ff2513072e955aacb72e9041790\``, + ); + await queryRunner.query( + `ALTER TABLE \`result\` DROP COLUMN \`qaed_comment\``, + ); + await queryRunner.query(`ALTER TABLE \`result\` DROP COLUMN \`qaed_date\``); + await queryRunner.query(`ALTER TABLE \`result\` DROP COLUMN \`qaed_user\``); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE \`result\` ADD \`qaed_user\` int NULL`, + ); + await queryRunner.query( + `ALTER TABLE \`result\` ADD \`qaed_date\` timestamp NULL`, + ); + await queryRunner.query( + `ALTER TABLE \`result\` ADD \`qaed_comment\` text COLLATE "utf8mb3_unicode_ci" NULL`, + ); + await queryRunner.query( + `ALTER TABLE \`result\` ADD CONSTRAINT \`FK_ff2513072e955aacb72e9041790\` FOREIGN KEY (\`qaed_user\`) REFERENCES \`users\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`, + ); + } +} diff --git a/onecgiar-pr-server/src/migrations/1731504619556-AddedResultQAedLogTable.ts b/onecgiar-pr-server/src/migrations/1731504619556-AddedResultQAedLogTable.ts new file mode 100644 index 000000000..e101aec49 --- /dev/null +++ b/onecgiar-pr-server/src/migrations/1731504619556-AddedResultQAedLogTable.ts @@ -0,0 +1,29 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class AddedResultQAedLogTable1731504619556 + implements MigrationInterface +{ + name = 'AddedResultQAedLogTable1731504619556'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE \`result_qaed_log\` (\`id\` bigint NOT NULL AUTO_INCREMENT, \`result_id\` bigint NOT NULL, \`qaed_date\` date NOT NULL, \`qaed_comments\` text NULL, \`qaed_user\` int NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`, + ); + await queryRunner.query( + `ALTER TABLE \`result_qaed_log\` ADD CONSTRAINT \`FK_9935d4ce4da5bb7b26cee090987\` FOREIGN KEY (\`result_id\`) REFERENCES \`result\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE \`result_qaed_log\` ADD CONSTRAINT \`FK_bee9006e35c169af6033da52a04\` FOREIGN KEY (\`qaed_user\`) REFERENCES \`users\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE \`result_qaed_log\` DROP FOREIGN KEY \`FK_bee9006e35c169af6033da52a04\``, + ); + await queryRunner.query( + `ALTER TABLE \`result_qaed_log\` DROP FOREIGN KEY \`FK_9935d4ce4da5bb7b26cee090987\``, + ); + await queryRunner.query(`DROP TABLE \`result_qaed_log\``); + } +}