feat: filtrar profesionales por ciudad con query param ?city=

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-27 19:26:33 -05:00
co-authored by Claude Sonnet 4.6
parent f94c2f96b0
commit 8a1f9687cd
2 changed files with 7 additions and 4 deletions
@@ -17,7 +17,8 @@ export class ProfessionalsController {
findAllActive(@Req() req) {
const page = +(req.query.page || 1);
const limit = +(req.query.limit || 20);
return this.pros.findAllActive(page, limit);
const city = req.query.city as string | undefined;
return this.pros.findAllActive(page, limit, city);
}
@Get('pending')
@@ -5,11 +5,13 @@ import { PrismaService } from '../prisma/prisma.service';
export class ProfessionalsService {
constructor(private prisma: PrismaService) {}
async findAllActive(page = 1, limit = 20) {
async findAllActive(page = 1, limit = 20, city?: string) {
const skip = (page - 1) * limit;
const where: any = { is_active: true };
if (city) where.users = { city: { contains: city, mode: 'insensitive' } };
const [data, total] = await Promise.all([
this.prisma.professionals.findMany({
where: { is_active: true },
where,
skip,
take: limit,
include: {
@@ -19,7 +21,7 @@ export class ProfessionalsService {
payment_methods: true,
},
}),
this.prisma.professionals.count({ where: { is_active: true } }),
this.prisma.professionals.count({ where }),
]);
return { data, meta: { total, page, limit, totalPages: Math.ceil(total / limit) || 1 } };
}