Skip to content

Commit f71b48d

Browse files
Merge pull request #311 from vidhiii1711/fix/roadmap-filter-limit-validation
fix: roadmap filters returning 400 due to limit validation mismatch
2 parents 0194f16 + ad034c8 commit f71b48d

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

server/src/module/roadmap/roadmap.service.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,19 @@ export async function listPublishedRoadmaps(opts: {
9090
if (opts.level && opts.level !== "ALL_LEVELS") {
9191
where.level = opts.level as "BEGINNER" | "INTERMEDIATE" | "ADVANCED" | "ALL_LEVELS";
9292
}
93-
if (opts.tag) {
94-
andConditions.push({ tags: { has: opts.tag } });
95-
}
96-
if (opts.category) {
97-
andConditions.push({ tags: { has: opts.category } });
98-
}
93+
// if (opts.tag) {
94+
// andConditions.push({ tags: { has: opts.tag } });
95+
// }
96+
// if (opts.category) {
97+
// andConditions.push({ tags: { has: opts.category } });
98+
// }
99+
const tagFilters: string[] = [];
100+
if (opts.tag) tagFilters.push(opts.tag);
101+
if (opts.category) tagFilters.push(opts.category);
102+
103+
if (tagFilters.length > 0) {
104+
andConditions.push({ tags: { hasSome: tagFilters } });
105+
}
99106
if (opts.search) {
100107
const s = opts.search.trim();
101108
if (s) {

server/src/module/roadmap/roadmap.validation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ export const pdfThemeQuery = z.object({
4949

5050
export const listQuerySchema = z.object({
5151
page: z.coerce.number().int().min(1).default(1),
52-
limit: z.coerce.number().int().min(1).max(50).default(20),
52+
// limit: z.coerce.number().int().min(1).max(50).default(20),
53+
limit: z.coerce.number().int().min(1).max(100).default(20),
5354
level: z.enum(["BEGINNER", "INTERMEDIATE", "ADVANCED", "ALL_LEVELS"]).optional(),
5455
search: z.string().optional(),
5556
tag: z.string().optional(),

0 commit comments

Comments
 (0)