Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/TM-1770 entity get index nursery report #101

Merged
merged 45 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
69bd420
[TM-1770] add fields and basic structure for nursery report
LimberHope Mar 21, 2025
620e655
[TM-1770] add nursery report dto
LimberHope Mar 21, 2025
c5ed797
[TM-1770] Merge branch 'staging' into feat/TM-1770_entity_get_index_n…
LimberHope Mar 21, 2025
e633d69
[TM-1770] add missing features
LimberHope Mar 24, 2025
3cded26
[TM-1770] fix lint
LimberHope Mar 24, 2025
b0030cd
[TM-1770] fix lint
LimberHope Mar 24, 2025
f9b4d24
[TM-1770] fix
LimberHope Mar 24, 2025
dd45cf8
[TM-1770] update order values
LimberHope Mar 24, 2025
a600a87
[TM-1770] add missing terms
LimberHope Mar 24, 2025
ebdd694
[TM-1770] [TM-1769] add nurseryUuid params in query dto
LimberHope Mar 24, 2025
f590496
[TM-1770] add more test cases
LimberHope Mar 24, 2025
5e52666
[TM-1770] fix lint
LimberHope Mar 24, 2025
d6a898f
[TM-1770] add more test cases
LimberHope Mar 24, 2025
eca2456
[TM-1770] remove non-sortable fields
LimberHope Mar 24, 2025
4ebfc46
[TM-1770] remove non-sortable fields
LimberHope Mar 24, 2025
60815c7
[TM-1770] add test
LimberHope Mar 24, 2025
230981c
[TM-1770] fix test
LimberHope Mar 24, 2025
9acd6d3
[TM-1770] update test
LimberHope Mar 24, 2025
d615cf7
[TM-1770] update test
LimberHope Mar 24, 2025
7121d70
[TM-1770] update test
LimberHope Mar 24, 2025
dd76056
[TM-1770] add missing property
LimberHope Mar 24, 2025
cdd3781
[TM-1770] add missing property
LimberHope Mar 24, 2025
0fb1bf5
[TM-1770] add missing sort fields
LimberHope Mar 24, 2025
fffc6bf
[TM-1770] fix lint
LimberHope Mar 24, 2025
f5c1c24
[TM-1770] add new test case
LimberHope Mar 24, 2025
7a62e59
[TM-1770] add new test case
LimberHope Mar 24, 2025
bc06505
[TM-1770] update test
LimberHope Mar 24, 2025
a0f10e8
[TM-1770] update test
LimberHope Mar 24, 2025
eb5c2ef
[TM-1770] update test
LimberHope Mar 24, 2025
9b02d49
[TM-1770] comment to test
LimberHope Mar 24, 2025
ba34b22
[TM-1770] remove comment
LimberHope Mar 24, 2025
8ce160c
[TM-1770] add unit test for project uuid filter on nursery reports
pachonjcl Mar 25, 2025
39d45fd
[TM-1770] fix test
pachonjcl Mar 25, 2025
200127e
[TM-1770] move expectation
pachonjcl Mar 25, 2025
d35ed0f
[TM-1770] fix coverage
pachonjcl Mar 25, 2025
79529b0
[TM-1770] Merge branch 'feat/TM-1770_entity_get_index_nursery_report'…
LimberHope Mar 26, 2025
bb87cc2
[TM-1770] resolve PR comments
LimberHope Mar 26, 2025
7dc344e
[TM-1770] fix lint
LimberHope Mar 26, 2025
a6085f6
[TM-1770] remove unnecessary properties
LimberHope Mar 26, 2025
e916f70
[TM-1770] Merge branch 'staging' into feat/TM-1770_entity_get_index_n…
LimberHope Mar 27, 2025
8f4fb7c
[TM-1770] changes from feedback
LimberHope Mar 27, 2025
537f0e3
[TM-1770] remove readable completion status property
LimberHope Mar 27, 2025
279f38b
[TM-1770] Merge branch 'staging' into feat/TM-1770_entity_get_index_n…
LimberHope Mar 27, 2025
2293ec5
[TM-1770] add properties to send the first and lastName
LimberHope Mar 27, 2025
93f91ed
[TM-1770] fix lint
LimberHope Mar 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/entity-service/src/entities/dto/entity-query.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ export class EntityQueryDto extends IntersectionType(QuerySort, NumberPage) {
@ApiProperty({ required: false })
@IsOptional()
projectUuid?: string;

@ApiProperty({ required: false })
@IsOptional()
nurseryUuid?: string;
}
233 changes: 233 additions & 0 deletions apps/entity-service/src/entities/dto/nursery-report.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
import { NurseryReport } from "@terramatch-microservices/database/entities";
import { EntityDto, AdditionalProps } from "./entity.dto";
import { pickApiProperties } from "@terramatch-microservices/common/dto/json-api-attributes";
import { JsonApiDto } from "@terramatch-microservices/common/decorators/json-api-dto.decorator";
import { ApiProperty } from "@nestjs/swagger";
import { MediaDto } from "./media.dto";

@JsonApiDto({ type: "nurseryReports" })
export class NurseryReportLightDto extends EntityDto {
constructor(nurseryReport?: NurseryReport, props?: AdditionalNurseryReportLightProps) {
super();
if (nurseryReport != null) {
this.populate(NurseryReportLightDto, {
...pickApiProperties(nurseryReport, NurseryReportLightDto),
lightResource: true,
// these two are untyped and marked optional in the base model.
createdAt: nurseryReport.createdAt as Date,
updatedAt: nurseryReport.updatedAt as Date,
...props
});
}
}

@ApiProperty({
nullable: true,
description: "The associated nursery name"
})
nurseryName: string | null;

@ApiProperty({
nullable: true,
description: "The associated nursery uuid"
})
nurseryUuid: string | null;

@ApiProperty()
frameworkKey: string | null;

@ApiProperty()
frameworkUuid: string | null;

@ApiProperty()
status: string;

@ApiProperty()
updateRequestStatus: string;

@ApiProperty({
nullable: true,
description: "The associated project name"
})
projectName: string | null;

@ApiProperty({
nullable: true,
description: "The associated project uuid"
})
projectUuid: string | null;

@ApiProperty({
nullable: true,
description: "The associated organisation name"
})
organisationName: string | null;

@ApiProperty({
nullable: true,
description: "The associated organisation uuid"
})
organisationUuid: string | null;

@ApiProperty()
updatedAt: Date;

@ApiProperty({ nullable: true })
submittedAt: Date | null;

@ApiProperty({ nullable: true })
taskUuid: string | null;

@ApiProperty()
dueAt: Date | null;

@ApiProperty({ nullable: true })
title: string | null;

@ApiProperty({ nullable: true })
reportTitle: string | null;

@ApiProperty()
createdAt: Date;
}

export type AdditionalNurseryReportLightProps = Pick<NurseryReportLightDto, "reportTitle">;
export type AdditionalNurseryReportFullProps = AdditionalNurseryReportLightProps &
AdditionalProps<NurseryReportFullDto, NurseryReportLightDto & Omit<NurseryReport, "nursery">>;
export type NurseryReportMedia = Pick<NurseryReportFullDto, keyof typeof NurseryReport.MEDIA>;

export class NurseryReportFullDto extends NurseryReportLightDto {
constructor(nurseryReport: NurseryReport, props?: AdditionalNurseryReportFullProps) {
super();
if (nurseryReport != null) {
this.populate(NurseryReportFullDto, {
...pickApiProperties(nurseryReport, NurseryReportFullDto),
lightResource: false,
// these two are untyped and marked optional in the base model.
createdAt: nurseryReport.createdAt as Date,
updatedAt: nurseryReport.updatedAt as Date,
...props
});
}
}

@ApiProperty({ nullable: true })
reportTitle: string | null;

@ApiProperty({ nullable: true })
projectReportTitle: string | null;

@ApiProperty({
nullable: true,
description: "The associated nursery name"
})
nurseryName: string | null;

@ApiProperty({
nullable: true,
description: "The associated nursery uuid"
})
nurseryUuid: string | null;

@ApiProperty({
nullable: true,
description: "The associated organisation name"
})
organisationName: string | null;

@ApiProperty({
nullable: true,
description: "The associated organisation uuid"
})
organisationUuid: string | null;

@ApiProperty()
dueAt: Date | null;

@ApiProperty()
status: string;

@ApiProperty()
updateRequestStatus: string;

@ApiProperty({ nullable: true })
feedback: string | null;

@ApiProperty({ nullable: true })
feedbackFields: string[] | null;

@ApiProperty()
nothingToReport: boolean;

@ApiProperty({ nullable: true })
completion: number | null;

@ApiProperty({ nullable: true })
title: string | null;

@ApiProperty({ nullable: true })
seedlingsYoungTrees: number | null;

@ApiProperty({ nullable: true })
interestingFacts: string | null;

@ApiProperty({ nullable: true })
sitePrep: string | null;

@ApiProperty({ nullable: true })
sharedDriveLink: string | null;

@ApiProperty({ nullable: true })
createdByFirstName: string | null;

@ApiProperty({ nullable: true })
createdByLastName: string | null;

@ApiProperty({ nullable: true })
approvedByFirstName: string | null;

@ApiProperty({ nullable: true })
approvedByLastName: string | null;

@ApiProperty({
nullable: true,
description: "The associated project name"
})
projectName: string | null;

@ApiProperty({
nullable: true,
description: "The associated project uuid"
})
projectUuid: string | null;

@ApiProperty({
nullable: true,
description: "The associated task uuid"
})
taskUuid: string | null;

@ApiProperty({ nullable: true })
submittedAt: Date | null;

@ApiProperty()
migrated: boolean;

@ApiProperty()
createdAt: Date;

@ApiProperty()
updatedAt: Date;

@ApiProperty({ type: () => MediaDto, isArray: true })
file: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
otherAdditionalDocuments: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
treeSeedlingContributions: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
photos: MediaDto[];
}
13 changes: 11 additions & 2 deletions apps/entity-service/src/entities/entities.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ProjectReportFullDto, ProjectReportLightDto } from "./dto/project-repor
import { NurseryFullDto, NurseryLightDto } from "./dto/nursery.dto";
import { EntityModel } from "@terramatch-microservices/database/constants/entities";
import { JsonApiDeletedResponse } from "@terramatch-microservices/common/decorators/json-api-response.decorator";
import { NurseryReportFullDto, NurseryReportLightDto } from "./dto/nursery-report.dto";

@Controller("entities/v3")
@ApiExtraModels(ANRDto, ProjectApplicationDto, MediaDto)
Expand All @@ -38,7 +39,8 @@ export class EntitiesController {
{ data: ProjectLightDto, pagination: "number" },
{ data: SiteLightDto, pagination: "number" },
{ data: NurseryLightDto, pagination: "number" },
{ data: ProjectReportLightDto, pagination: "number" }
{ data: ProjectReportLightDto, pagination: "number" },
{ data: NurseryReportLightDto, pagination: "number" }
])
@ExceptionResponse(BadRequestException, { description: "Query params invalid" })
async entityIndex<T extends EntityModel>(@Param() { entity }: EntityIndexParamsDto, @Query() query: EntityQueryDto) {
Expand Down Expand Up @@ -69,7 +71,14 @@ export class EntitiesController {
operationId: "entityGet",
summary: "Get a single full entity resource by UUID"
})
@JsonApiResponse([ProjectFullDto, SiteFullDto, NurseryFullDto, ProjectReportFullDto])
@JsonApiResponse([
ProjectFullDto,
SiteFullDto,
NurseryFullDto,
NurseryFullDto,
ProjectReportFullDto,
NurseryReportFullDto
])
@ExceptionResponse(UnauthorizedException, {
description: "Authentication failed, or resource unavailable to current user."
})
Expand Down
4 changes: 3 additions & 1 deletion apps/entity-service/src/entities/entities.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ import { UuidModel } from "@terramatch-microservices/database/types/util";
import { SeedingDto } from "./dto/seeding.dto";
import { TreeSpeciesDto } from "./dto/tree-species.dto";
import { DemographicDto } from "./dto/demographic.dto";
import { NurseryReportProcessor } from "./processors/nursery-report.processor";

// The keys of this array must match the type in the resulting DTO.
const ENTITY_PROCESSORS = {
projects: ProjectProcessor,
sites: SiteProcessor,
nurseries: NurseryProcessor,
projectReports: ProjectReportProcessor
projectReports: ProjectReportProcessor,
nurseryReports: NurseryReportProcessor
};

export type ProcessableEntity = keyof typeof ENTITY_PROCESSORS;
Expand Down
Loading