This commit is contained in:
Scott Wilson
2025-09-15 10:58:57 -07:00
parent 8fee3c3882
commit 1f4b50a6e0
12 changed files with 269 additions and 104 deletions
@@ -1064,6 +1064,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
type: z.nativeEnum(ProjectType).optional(),
orderBy: z.nativeEnum(SearchProjectSortBy).optional().default(SearchProjectSortBy.NAME),
orderDirection: z.nativeEnum(SortDirection).optional().default(SortDirection.ASC),
projectIds: z.string().trim().array().optional(),
name: z
.string()
.trim()
@@ -399,6 +399,7 @@ export const projectDALFactory = (db: TDbClient) => {
name?: string;
sortBy?: SearchProjectSortBy;
sortDir?: SortDirection;
projectIds?: string[];
}) => {
const { limit = 20, offset = 0, sortBy = SearchProjectSortBy.NAME, sortDir = SortDirection.ASC } = dto;
@@ -454,6 +455,11 @@ export const projectDALFactory = (db: TDbClient) => {
if (dto.name) {
void query.whereILike(`${TableName.Project}.name`, `%${dto.name}%`);
}
if (dto.projectIds?.length) {
void query.whereIn(`${TableName.Project}.id`, dto.projectIds);
}
const docs = await query;
return { docs, totalCount: Number(docs?.[0]?.count ?? 0) };
@@ -1806,7 +1806,8 @@ export const projectServiceFactory = ({
limit,
type,
orderBy,
orderDirection
orderDirection,
projectIds
}: TSearchProjectsDTO) => {
// check user belong to org
await permissionService.getOrgPermission(
@@ -1822,6 +1823,7 @@ export const projectServiceFactory = ({
offset,
name,
type,
projectIds,
orgId: permission.orgId,
actor: permission.type,
actorId: permission.id,
@@ -221,6 +221,7 @@ export type TSearchProjectsDTO = {
limit?: number;
offset?: number;
orderBy?: SearchProjectSortBy;
projectIds?: string[];
orderDirection?: SortDirection;
};