From c48898ec056be355c0113767e6096447acac0980 Mon Sep 17 00:00:00 2001 From: Everton Pavan Date: Sat, 14 Sep 2024 18:24:59 -0300 Subject: [PATCH] feat: add capacity and sheltered pets (#126) add fields in shelter table: pets capacity and sheltered pets Task: https://sosriograndedosul.notion.site/Quando-o-abrigo-aceita-pets-habilitar-quantidade-de-vagas-e-capacidade-para-pets-414804de03f541d795e34baff7ee2371 Frontend PR is here: [https://github.com/SOS-RS/frontend/pull/206](https://github.com/SOS-RS/frontend/pull/206) --------- Co-authored-by: Everton Pavan --- .../migration.sql | 3 +++ prisma/schema.prisma | 2 ++ src/shelter/shelter.service.ts | 4 ++++ src/shelter/types/types.ts | 4 ++++ 4 files changed, 13 insertions(+) create mode 100644 prisma/migrations/20240516140110_add_capacity_and_shelter_pets/migration.sql diff --git a/prisma/migrations/20240516140110_add_capacity_and_shelter_pets/migration.sql b/prisma/migrations/20240516140110_add_capacity_and_shelter_pets/migration.sql new file mode 100644 index 00000000..de70c354 --- /dev/null +++ b/prisma/migrations/20240516140110_add_capacity_and_shelter_pets/migration.sql @@ -0,0 +1,3 @@ +-- AlterTable +ALTER TABLE "shelters" ADD COLUMN "pets_capacity" INTEGER, +ADD COLUMN "sheltered_pets" INTEGER; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 1a4b82f5..11c893a7 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -120,6 +120,8 @@ model Shelter { streetNumber String? @map("street_number") zipCode String? @map("zip_code") petFriendly Boolean? @map("pet_friendly") + shelteredPets Int? @map("sheltered_pets") + petsCapacity Int? @map("pets_capacity") shelteredPeople Int? @map("sheltered_people") capacity Int? contact String? diff --git a/src/shelter/shelter.service.ts b/src/shelter/shelter.service.ts index 9aee0f0d..e3a4a59e 100644 --- a/src/shelter/shelter.service.ts +++ b/src/shelter/shelter.service.ts @@ -86,6 +86,8 @@ export class ShelterService implements OnModuleInit { capacity: true, contact: shouldShowContact, petFriendly: true, + shelteredPets: true, + petsCapacity: true, prioritySum: true, latitude: true, longitude: true, @@ -165,6 +167,8 @@ export class ShelterService implements OnModuleInit { zipCode: true, capacity: true, petFriendly: true, + shelteredPets: true, + petsCapacity: true, shelteredPeople: true, prioritySum: true, verified: true, diff --git a/src/shelter/types/types.ts b/src/shelter/types/types.ts index c2361788..f95593f4 100644 --- a/src/shelter/types/types.ts +++ b/src/shelter/types/types.ts @@ -19,6 +19,8 @@ const ShelterSchema = z.object({ streetNumber: z.string().nullable().optional(), zipCode: z.string().nullable().optional(), petFriendly: z.boolean().nullable().optional(), + shelteredPets: z.number().min(0).nullable().optional(), + petsCapacity: z.number().min(0).nullable().optional(), shelteredPeople: z.number().min(0).nullable().optional(), latitude: z.number().nullable().optional(), longitude: z.number().nullable().optional(), @@ -39,6 +41,8 @@ const CreateShelterSchema = ShelterSchema.omit({ const UpdateShelterSchema = ShelterSchema.pick({ petFriendly: true, shelteredPeople: true, + shelteredPets: true, + petsCapacity: true, }).partial(); const FullUpdateShelterSchema = ShelterSchema.omit({