Skip to content

Commit

Permalink
Merge branch 'P2-1109-User-story-7-Tracking-Quality-Assessed-status-i…
Browse files Browse the repository at this point in the history
…n-PRMS-Reporting-Tool' into dev
  • Loading branch information
JuanGuzman-io committed Nov 13, 2024
2 parents ebbf218 + 15ffcdd commit 8eb018a
Show file tree
Hide file tree
Showing 11 changed files with 184 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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>(ResultQaedController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
Original file line number Diff line number Diff line change
@@ -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) {}
}
9 changes: 9 additions & 0 deletions onecgiar-pr-server/src/api/result-qaed/result-qaed.module.ts
Original file line number Diff line number Diff line change
@@ -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 {}
18 changes: 18 additions & 0 deletions onecgiar-pr-server/src/api/result-qaed/result-qaed.service.spec.ts
Original file line number Diff line number Diff line change
@@ -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>(ResultQaedService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
4 changes: 4 additions & 0 deletions onecgiar-pr-server/src/api/result-qaed/result-qaed.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class ResultQaedService {}
32 changes: 4 additions & 28 deletions onecgiar-pr-server/src/api/results/entities/result.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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[];

Expand Down Expand Up @@ -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[];
}
2 changes: 2 additions & 0 deletions onecgiar-pr-server/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -78,6 +79,7 @@ import { EmailNotificationManagementModule } from './shared/microservices/email-
UserNotificationSettingsModule,
EmailNotificationManagementModule,
NotificationModule,
ResultQaedModule,
],
controllers: [AppController],
providers: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down Expand Up @@ -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[];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class RemovedQATrackingFieldsFromResult1731503453561
implements MigrationInterface
{
name = 'RemovedQATrackingFieldsFromResult1731503453561';

public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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`,
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddedResultQAedLogTable1731504619556
implements MigrationInterface
{
name = 'AddedResultQAedLogTable1731504619556';

public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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\``);
}
}

0 comments on commit 8eb018a

Please sign in to comment.