From ff6926c0e3b24eba30e9096895df446e0b63e1a2 Mon Sep 17 00:00:00 2001 From: Felipe Barreta Date: Wed, 30 Oct 2024 16:03:35 -0700 Subject: [PATCH 1/4] ALCS-2345 Backend implementation --- .../notice-of-intent-tag.controller.spec.ts | 18 ++++ .../notice-of-intent-tag.controller.ts | 34 ++++++++ .../notice-of-intent-tag.dto.ts | 6 ++ .../notice-of-intent-tag.service.spec.ts | 18 ++++ .../notice-of-intent-tag.service.ts | 84 +++++++++++++++++++ .../notice-of-intent.entity.ts | 29 +++---- .../notice-of-intent.module.ts | 7 ++ services/apps/alcs/src/alcs/tag/tag.entity.ts | 6 +- services/apps/alcs/src/alcs/tag/tag.module.ts | 1 + .../1730326975258-add_tags_to_noi.ts | 22 +++++ 10 files changed, 205 insertions(+), 20 deletions(-) create mode 100644 services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.spec.ts create mode 100644 services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.ts create mode 100644 services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.dto.ts create mode 100644 services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.spec.ts create mode 100644 services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.ts create mode 100644 services/apps/alcs/src/providers/typeorm/migrations/1730326975258-add_tags_to_noi.ts diff --git a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.spec.ts b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.spec.ts new file mode 100644 index 0000000000..fd554a2ed2 --- /dev/null +++ b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { NoticeOfIntentTagController } from './notice-of-intent-tag.controller'; + +describe('NoticeOfIntentTagController', () => { + let controller: NoticeOfIntentTagController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [NoticeOfIntentTagController], + }).compile(); + + controller = module.get(NoticeOfIntentTagController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.ts b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.ts new file mode 100644 index 0000000000..dd14936949 --- /dev/null +++ b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.ts @@ -0,0 +1,34 @@ +import { Body, Controller, Delete, Get, Logger, Param, Post, UseGuards } from '@nestjs/common'; +import { ApiOAuth2 } from '@nestjs/swagger'; +import { RolesGuard } from '../../../common/authorization/roles-guard.service'; +import * as config from 'config'; +import { UserRoles } from '../../../common/authorization/roles.decorator'; +import { ROLES_ALLOWED_APPLICATIONS } from '../../../common/authorization/roles'; +import { NoticeOfIntentTagService } from './notice-of-intent-tag.service'; +import { NoticeOfIntentTagDto } from './notice-of-intent-tag.dto'; + +@Controller('notice-of-intent/:fileNumber/tag') +@ApiOAuth2(config.get('KEYCLOAK.SCOPES')) +@UseGuards(RolesGuard) +export class NoticeOfIntentTagController { + private logger = new Logger(NoticeOfIntentTagController.name); + constructor(private service: NoticeOfIntentTagService) {} + + @Get('') + @UserRoles(...ROLES_ALLOWED_APPLICATIONS) + async getApplicationTags(@Param('fileNumber') fileNumber: string) { + return await this.service.getNoticeOfIntentTags(fileNumber); + } + + @Post('') + @UserRoles(...ROLES_ALLOWED_APPLICATIONS) + async addTagToApplication(@Param('fileNumber') fileNumber: string, @Body() dto: NoticeOfIntentTagDto) { + return await this.service.addTagToNoticeOfIntent(fileNumber, dto.tagName); + } + + @Delete('/:tagName') + @UserRoles(...ROLES_ALLOWED_APPLICATIONS) + async removeTagFromApplication(@Param('fileNumber') fileNumber: string, @Param('tagName') tagName: string) { + return await this.service.removeTagFromNoticeOfIntent(fileNumber, tagName); + } +} diff --git a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.dto.ts b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.dto.ts new file mode 100644 index 0000000000..d96ffe7bb2 --- /dev/null +++ b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.dto.ts @@ -0,0 +1,6 @@ +import { IsString } from 'class-validator'; + +export class NoticeOfIntentTagDto { + @IsString() + tagName: string; +} diff --git a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.spec.ts b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.spec.ts new file mode 100644 index 0000000000..40ec6e4ea7 --- /dev/null +++ b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { NoticeOfIntentTagService } from './notice-of-intent-tag.service'; + +describe('NoticeOfIntentTagService', () => { + let service: NoticeOfIntentTagService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [NoticeOfIntentTagService], + }).compile(); + + service = module.get(NoticeOfIntentTagService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.ts b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.ts new file mode 100644 index 0000000000..ec9bd6445b --- /dev/null +++ b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.ts @@ -0,0 +1,84 @@ +import { Injectable, Logger } from '@nestjs/common'; +import { InjectRepository } from '@nestjs/typeorm'; +import { Tag } from '../../tag/tag.entity'; +import { NoticeOfIntent } from '../notice-of-intent.entity'; +import { Repository } from 'typeorm'; +import { ServiceNotFoundException, ServiceValidationException } from '@app/common/exceptions/base.exception'; + +@Injectable() +export class NoticeOfIntentTagService { + private logger = new Logger(NoticeOfIntentTagService.name); + + constructor( + @InjectRepository(Tag) private tagRepository: Repository, + @InjectRepository(NoticeOfIntent) private noiRepository: Repository, + ) {} + + async addTagToNoticeOfIntent(fileNumber: string, tagName: string) { + const noi = await this.noiRepository.findOne({ + where: { fileNumber: fileNumber }, + relations: ['tags'], + }); + if (!noi) { + throw new ServiceNotFoundException(`Notice of Intent not found with number ${fileNumber}`); + } + + const tag = await this.tagRepository.findOne({ where: { name: tagName } }); + if (!tag) { + throw new ServiceNotFoundException(`Tag not found with name ${tagName}`); + } + + if (!noi.tags) { + noi.tags = []; + } + + const tagExists = noi.tags.some((t) => t.uuid === tag.uuid); + console.log(tagExists); + if (tagExists) { + throw new ServiceValidationException(`Tag ${tagName} already exists`); + } + + noi.tags.push(tag); + return this.noiRepository.save(noi); + } + + async removeTagFromNoticeOfIntent(fileNumber: string, tagName: string) { + const noi = await this.noiRepository.findOne({ + where: { fileNumber: fileNumber }, + relations: ['tags'], + }); + if (!noi) { + throw new ServiceNotFoundException(`Notice of Intent not found with number ${fileNumber}`); + } + + const tag = await this.tagRepository.findOne({ where: { name: tagName } }); + if (!tag) { + throw new ServiceNotFoundException(`Tag not found with name ${tagName}`); + } + + if (!noi.tags) { + noi.tags = []; + } + + const tagExists = noi.tags.some((t) => t.uuid === tag.uuid); + if (!tagExists) { + throw new ServiceValidationException(`Tag ${tagName} does not exist`); + } + + noi.tags = noi.tags.filter((t) => t.uuid !== tag.uuid); + return this.noiRepository.save(noi); + } + + async getNoticeOfIntentTags(fileNumber: string) { + const noi = await this.noiRepository.findOne({ + where: { fileNumber: fileNumber }, + relations: ['tags'], + }); + if (!noi) { + throw new ServiceNotFoundException(`Notice of Intent not found with number ${fileNumber}`); + } + return noi.tags && noi.tags.length > 0 + ? noi.tags.sort((a, b) => a.auditCreatedAt.getTime() - b.auditCreatedAt.getTime()) + : []; + } +} diff --git a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent.entity.ts b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent.entity.ts index 2ef0aa8518..58a559aafb 100644 --- a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent.entity.ts +++ b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent.entity.ts @@ -1,16 +1,6 @@ import { AutoMap } from 'automapper-classes'; import { Type } from 'class-transformer'; -import { - Column, - Entity, - Index, - JoinColumn, - JoinTable, - ManyToMany, - ManyToOne, - OneToMany, - OneToOne, -} from 'typeorm'; +import { Column, Entity, Index, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToMany, OneToOne } from 'typeorm'; import { Base } from '../../common/entities/base.entity'; import { ColumnNumericTransformer } from '../../utils/column-numeric-transform'; import { Card } from '../card/card.entity'; @@ -19,10 +9,10 @@ import { LocalGovernment } from '../local-government/local-government.entity'; import { NoticeOfIntentDocument } from './notice-of-intent-document/notice-of-intent-document.entity'; import { NoticeOfIntentSubtype } from './notice-of-intent-subtype.entity'; import { NoticeOfIntentType } from './notice-of-intent-type/notice-of-intent-type.entity'; +import { Tag } from '../tag/tag.entity'; @Entity({ - comment: - 'Base data for Notice of Intents incl. the ID, key dates, and the date of the first decision', + comment: 'Base data for Notice of Intents incl. the ID, key dates, and the date of the first decision', }) export class NoticeOfIntent extends Base { constructor(data?: Partial) { @@ -171,8 +161,7 @@ export class NoticeOfIntent extends Base { @AutoMap(() => String) @Column({ type: 'text', - comment: - 'NOI Id that is applicable only to paper version applications from 70s - 80s', + comment: 'NOI Id that is applicable only to paper version applications from 70s - 80s', nullable: true, }) legacyId?: string | null; @@ -247,9 +236,11 @@ export class NoticeOfIntent extends Base { typeCode: string; @AutoMap() - @OneToMany( - () => NoticeOfIntentDocument, - (noiDocument) => noiDocument.noticeOfIntent, - ) + @OneToMany(() => NoticeOfIntentDocument, (noiDocument) => noiDocument.noticeOfIntent) documents: NoticeOfIntentDocument[]; + + @AutoMap(() => [Tag]) + @ManyToMany(() => Tag, (tag) => tag.noticeOfIntents) + @JoinTable({ name: 'notice_of_intent_tag' }) + tags: Tag[]; } diff --git a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent.module.ts b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent.module.ts index 10ec091d6a..1629df1c41 100644 --- a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent.module.ts +++ b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent.module.ts @@ -29,6 +29,9 @@ import { NoticeOfIntentType } from './notice-of-intent-type/notice-of-intent-typ import { NoticeOfIntentController } from './notice-of-intent.controller'; import { NoticeOfIntent } from './notice-of-intent.entity'; import { NoticeOfIntentService } from './notice-of-intent.service'; +import { TagModule } from '../tag/tag.module'; +import { NoticeOfIntentTagService } from './notice-of-intent-tag/notice-of-intent-tag.service'; +import { NoticeOfIntentTagController } from './notice-of-intent-tag/notice-of-intent-tag.controller'; @Module({ imports: [ @@ -52,6 +55,7 @@ import { NoticeOfIntentService } from './notice-of-intent.service'; LocalGovernmentModule, NoticeOfIntentSubmissionStatusModule, forwardRef(() => NoticeOfIntentSubmissionModule), + TagModule, ], providers: [ NoticeOfIntentService, @@ -60,6 +64,7 @@ import { NoticeOfIntentService } from './notice-of-intent.service'; NoticeOfIntentDocumentService, NoticeOfIntentSubmissionService, NoticeOfIntentParcelProfile, + NoticeOfIntentTagService, ], controllers: [ NoticeOfIntentController, @@ -67,12 +72,14 @@ import { NoticeOfIntentService } from './notice-of-intent.service'; NoticeOfIntentDocumentController, NoticeOfIntentSubmissionController, NoticeOfIntentParcelController, + NoticeOfIntentTagController, ], exports: [ NoticeOfIntentService, NoticeOfIntentMeetingService, NoticeOfIntentDocumentService, NoticeOfIntentSubmissionService, + NoticeOfIntentTagService, ], }) export class NoticeOfIntentModule {} diff --git a/services/apps/alcs/src/alcs/tag/tag.entity.ts b/services/apps/alcs/src/alcs/tag/tag.entity.ts index 0ddd5c09d2..88bda449bc 100644 --- a/services/apps/alcs/src/alcs/tag/tag.entity.ts +++ b/services/apps/alcs/src/alcs/tag/tag.entity.ts @@ -1,7 +1,8 @@ import { AutoMap } from 'automapper-classes'; -import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; +import { Column, Entity, ManyToMany, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; import { Base } from '../../common/entities/base.entity'; import { TagCategory } from './tag-category/tag-category.entity'; +import { NoticeOfIntent } from '../notice-of-intent/notice-of-intent.entity'; @Entity({ comment: 'Tag.' }) export class Tag extends Base { @@ -28,4 +29,7 @@ export class Tag extends Base { nullable: true, }) category?: TagCategory | null; + + @ManyToMany(() => NoticeOfIntent, (noticeOfIntent) => noticeOfIntent.tags) + noticeOfIntents: NoticeOfIntent[]; } diff --git a/services/apps/alcs/src/alcs/tag/tag.module.ts b/services/apps/alcs/src/alcs/tag/tag.module.ts index 2e14ffd1dc..af644790b5 100644 --- a/services/apps/alcs/src/alcs/tag/tag.module.ts +++ b/services/apps/alcs/src/alcs/tag/tag.module.ts @@ -11,5 +11,6 @@ import { TagService } from './tag.service'; imports: [TypeOrmModule.forFeature([TagCategory, Tag])], controllers: [TagCategoryController, TagController], providers: [TagCategoryService, TagService], + exports: [TypeOrmModule], }) export class TagModule {} diff --git a/services/apps/alcs/src/providers/typeorm/migrations/1730326975258-add_tags_to_noi.ts b/services/apps/alcs/src/providers/typeorm/migrations/1730326975258-add_tags_to_noi.ts new file mode 100644 index 0000000000..a378d7d6fc --- /dev/null +++ b/services/apps/alcs/src/providers/typeorm/migrations/1730326975258-add_tags_to_noi.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddTagsToNoi1730326975258 implements MigrationInterface { + name = 'AddTagsToNoi1730326975258' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE "alcs"."notice_of_intent_tag" ("notice_of_intent_uuid" uuid NOT NULL, "tag_uuid" uuid NOT NULL, CONSTRAINT "PK_8ae82272ffcbd27427172fd5e11" PRIMARY KEY ("notice_of_intent_uuid", "tag_uuid"))`); + await queryRunner.query(`CREATE INDEX "IDX_2baab887c8e66032ba78750b91" ON "alcs"."notice_of_intent_tag" ("notice_of_intent_uuid") `); + await queryRunner.query(`CREATE INDEX "IDX_404540b8fc70a267572f0d506a" ON "alcs"."notice_of_intent_tag" ("tag_uuid") `); + await queryRunner.query(`ALTER TABLE "alcs"."notice_of_intent_tag" ADD CONSTRAINT "FK_2baab887c8e66032ba78750b912" FOREIGN KEY ("notice_of_intent_uuid") REFERENCES "alcs"."notice_of_intent"("uuid") ON DELETE CASCADE ON UPDATE CASCADE`); + await queryRunner.query(`ALTER TABLE "alcs"."notice_of_intent_tag" ADD CONSTRAINT "FK_404540b8fc70a267572f0d506aa" FOREIGN KEY ("tag_uuid") REFERENCES "alcs"."tag"("uuid") ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "alcs"."notice_of_intent_tag" DROP CONSTRAINT "FK_404540b8fc70a267572f0d506aa"`); + await queryRunner.query(`ALTER TABLE "alcs"."notice_of_intent_tag" DROP CONSTRAINT "FK_2baab887c8e66032ba78750b912"`); + await queryRunner.query(`DROP INDEX "alcs"."IDX_404540b8fc70a267572f0d506a"`); + await queryRunner.query(`DROP INDEX "alcs"."IDX_2baab887c8e66032ba78750b91"`); + await queryRunner.query(`DROP TABLE "alcs"."notice_of_intent_tag"`); + } + +} From cca19c9dbe38ce23f9d4e94e37a9ea4d9b729b98 Mon Sep 17 00:00:00 2001 From: Felipe Barreta Date: Wed, 30 Oct 2024 16:35:59 -0700 Subject: [PATCH 2/4] ALCS-2345 Fix failed tests --- .../notice-of-intent-tag.controller.spec.ts | 13 ++++++++++++ .../notice-of-intent-tag.service.spec.ts | 20 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.spec.ts b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.spec.ts index fd554a2ed2..1c998ad9c2 100644 --- a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.spec.ts +++ b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.spec.ts @@ -1,12 +1,25 @@ import { Test, TestingModule } from '@nestjs/testing'; import { NoticeOfIntentTagController } from './notice-of-intent-tag.controller'; +import { NoticeOfIntentTagService } from './notice-of-intent-tag.service'; +import { DeepMocked } from '@golevelup/nestjs-testing'; +import { ClsService } from 'nestjs-cls'; +import { mockKeyCloakProviders } from '../../../../test/mocks/mockTypes'; describe('NoticeOfIntentTagController', () => { let controller: NoticeOfIntentTagController; + let tagService: DeepMocked; beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ controllers: [NoticeOfIntentTagController], + providers: [ + { provide: NoticeOfIntentTagService, useValue: tagService }, + { + provide: ClsService, + useValue: {}, + }, + ...mockKeyCloakProviders, + ], }).compile(); controller = module.get(NoticeOfIntentTagController); diff --git a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.spec.ts b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.spec.ts index 40ec6e4ea7..f03153fc76 100644 --- a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.spec.ts +++ b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.spec.ts @@ -1,12 +1,30 @@ import { Test, TestingModule } from '@nestjs/testing'; import { NoticeOfIntentTagService } from './notice-of-intent-tag.service'; +import { getRepositoryToken } from '@nestjs/typeorm'; +import { NoticeOfIntent } from '../notice-of-intent.entity'; +import { createMock, DeepMocked } from '@golevelup/nestjs-testing'; +import { Repository } from 'typeorm'; +import { Tag } from '../../tag/tag.entity'; describe('NoticeOfIntentTagService', () => { let service: NoticeOfIntentTagService; + let noiRepository: DeepMocked>; + let tagRepository: DeepMocked>; beforeEach(async () => { + noiRepository = createMock(); const module: TestingModule = await Test.createTestingModule({ - providers: [NoticeOfIntentTagService], + providers: [ + NoticeOfIntentTagService, + { + provide: getRepositoryToken(NoticeOfIntent), + useValue: noiRepository, + }, + { + provide: getRepositoryToken(Tag), + useValue: tagRepository, + }, + ], }).compile(); service = module.get(NoticeOfIntentTagService); From c1b6cca22ec3ca330e3360e50290d5ce3dfce448 Mon Sep 17 00:00:00 2001 From: Felipe Barreta Date: Thu, 31 Oct 2024 08:43:39 -0700 Subject: [PATCH 3/4] ALCS-2345 Remove logger --- .../notice-of-intent-tag/notice-of-intent-tag.controller.ts | 3 +-- .../notice-of-intent-tag/notice-of-intent-tag.service.ts | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.ts b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.ts index dd14936949..b8b8238516 100644 --- a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.ts +++ b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.controller.ts @@ -1,4 +1,4 @@ -import { Body, Controller, Delete, Get, Logger, Param, Post, UseGuards } from '@nestjs/common'; +import { Body, Controller, Delete, Get, Param, Post, UseGuards } from '@nestjs/common'; import { ApiOAuth2 } from '@nestjs/swagger'; import { RolesGuard } from '../../../common/authorization/roles-guard.service'; import * as config from 'config'; @@ -11,7 +11,6 @@ import { NoticeOfIntentTagDto } from './notice-of-intent-tag.dto'; @ApiOAuth2(config.get('KEYCLOAK.SCOPES')) @UseGuards(RolesGuard) export class NoticeOfIntentTagController { - private logger = new Logger(NoticeOfIntentTagController.name); constructor(private service: NoticeOfIntentTagService) {} @Get('') diff --git a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.ts b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.ts index ec9bd6445b..42336fe2a5 100644 --- a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.ts +++ b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.ts @@ -1,4 +1,4 @@ -import { Injectable, Logger } from '@nestjs/common'; +import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Tag } from '../../tag/tag.entity'; import { NoticeOfIntent } from '../notice-of-intent.entity'; @@ -7,8 +7,6 @@ import { ServiceNotFoundException, ServiceValidationException } from '@app/commo @Injectable() export class NoticeOfIntentTagService { - private logger = new Logger(NoticeOfIntentTagService.name); - constructor( @InjectRepository(Tag) private tagRepository: Repository, @InjectRepository(NoticeOfIntent) private noiRepository: Repository, From afde00ed006fd899f2287465912f2ee23bb3bc5e Mon Sep 17 00:00:00 2001 From: Felipe Barreta Date: Thu, 31 Oct 2024 08:48:19 -0700 Subject: [PATCH 4/4] ALCS-2345 Database sort --- .../notice-of-intent-tag/notice-of-intent-tag.service.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.ts b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.ts index 42336fe2a5..4b7c988375 100644 --- a/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.ts +++ b/services/apps/alcs/src/alcs/notice-of-intent/notice-of-intent-tag/notice-of-intent-tag.service.ts @@ -71,12 +71,11 @@ export class NoticeOfIntentTagService { const noi = await this.noiRepository.findOne({ where: { fileNumber: fileNumber }, relations: ['tags'], + order: { auditCreatedAt: 'ASC' }, }); if (!noi) { throw new ServiceNotFoundException(`Notice of Intent not found with number ${fileNumber}`); } - return noi.tags && noi.tags.length > 0 - ? noi.tags.sort((a, b) => a.auditCreatedAt.getTime() - b.auditCreatedAt.getTime()) - : []; + return noi.tags && noi.tags.length > 0 ? noi.tags : []; } }