feat(requestlist): add requests list media type filtering (#1511)

* feat: add requests list media type filtering

* chore: some better indent

* fix(lint): missing break statements before case

* fix: yet another lint issue

* fix(lint): yet another lint issue

* Revert "fix(lint): yet another lint issue"

This reverts commit 24c3f90ed0.

* fix: lint issues
This commit is contained in:
0xsysr3ll
2025-05-07 16:41:06 +02:00
committed by GitHub
parent d01f9a0580
commit e8f1edc062
3 changed files with 73 additions and 4 deletions

View File

@@ -38,6 +38,7 @@ requestRoutes.get<Record<string, unknown>, RequestResultsResponse>(
const requestedBy = req.query.requestedBy
? Number(req.query.requestedBy)
: null;
const mediaType = (req.query.mediaType as MediaType | 'all') || 'all';
let statusFilter: MediaRequestStatus[];
@@ -159,6 +160,21 @@ requestRoutes.get<Record<string, unknown>, RequestResultsResponse>(
});
}
switch (mediaType) {
case 'all':
break;
case 'movie':
query = query.andWhere('request.type = :type', {
type: MediaType.MOVIE,
});
break;
case 'tv':
query = query.andWhere('request.type = :type', {
type: MediaType.TV,
});
break;
}
const [requests, requestCount] = await query
.orderBy(sortFilter, sortDirection)
.take(pageSize)