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

filter types #341

Merged
merged 11 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 15 additions & 8 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ datasource db {
}

model recreation_resource {
rec_resource_id String @id @db.VarChar(200)
name String? @db.VarChar(200)
description String? @db.VarChar(5000)
closest_community String? @db.VarChar(200)
display_on_public_site Boolean? @default(false)
rec_resource_type String? @db.VarChar(50)
rec_resource_id String @id @db.VarChar(200)
name String? @db.VarChar(200)
description String? @db.VarChar(5000)
closest_community String? @db.VarChar(200)
display_on_public_site Boolean? @default(false)
rec_resource_type String @db.VarChar(10)
campsite_count Int? @default(0)
recreation_activity recreation_activity[]
recreation_status recreation_status?
recreation_activity recreation_activity[]
recreation_resource_type_code recreation_resource_type_code @relation(fields: [rec_resource_type], references: [rec_resource_type_code], onDelete: NoAction, onUpdate: NoAction)
recreation_status recreation_status?
}

/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
Expand Down Expand Up @@ -50,3 +51,9 @@ model recreation_status_code {
description String @db.VarChar(120)
recreation_status recreation_status[]
}

model recreation_resource_type_code {
rec_resource_type_code String @id @db.VarChar(10)
description String? @db.VarChar(200)
recreation_resource recreation_resource[]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class FilterOptionDto {
description: "Unique identifier for the filter option",
example: 1,
})
id: number;
id: string | number;

@ApiProperty({
description: "Number of matching results for this filter",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe("Recreation DTOs", () => {
description:
"A scenic campground nestled in the heart of Evergreen Valley",
closest_community: "123 Forest Road, Mountain View, CA 94043",
rec_resource_type: "RR",
recreation_activity: [
{
recreation_activity_code: 1,
Expand All @@ -67,6 +68,9 @@ describe("Recreation DTOs", () => {
expect(resource.name.length).toBeLessThanOrEqual(100);
expect(Array.isArray(resource.recreation_activity)).toBeTruthy();
expect(resource.recreation_status).toBeDefined();
expect(resource.description).toBeDefined();
expect(resource.closest_community).toBeDefined();
expect(resource.rec_resource_type).toBeDefined();
});

it("should allow null description", () => {
Expand All @@ -75,6 +79,7 @@ describe("Recreation DTOs", () => {
name: "Test Resource",
description: null,
closest_community: "Test Location",
rec_resource_type: "RR",
recreation_activity: [],
recreation_status: {
status_code: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe("RecreationResourceController", () => {
closest_community: "Rec site 1 location",
recreation_activity: [],
display_on_public_site: true,
rec_resource_type: "RR",
recreation_status: {
description: "Active",
comment: "Active",
Expand Down Expand Up @@ -79,6 +80,7 @@ describe("RecreationResourceController", () => {
name: "Rec site 1",
description: "Rec site 1 description",
closest_community: "Rec site 1 location",
rec_resource_type: "RR",
recreation_activity: [],
recreation_status: {
description: "Active",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ export class RecreationResourceController {
type: String,
description: "Recreation activities",
})
@ApiQuery({
name: "type",
required: false,
type: String,
description: "Recreation resource type",
})
@ApiResponse({
status: 200,
description: "Resources found",
Expand All @@ -50,13 +56,15 @@ export class RecreationResourceController {
@Query("limit") limit?: number,
@Query("page") page: number = 1,
@Query("activities") activities?: string,
@Query("type") type?: string,
): Promise<PaginatedRecreationResourceDto> {
const response =
await this.recreationResourceService.searchRecreationResources(
page,
filter ?? "",
limit ? parseInt(String(limit)) : undefined,
activities,
type,
);

return response;
Expand Down
Loading
Loading