Skip to content

Commit

Permalink
limit updated
Browse files Browse the repository at this point in the history
  • Loading branch information
sinanptm committed Sep 12, 2024
1 parent 2e0ebbc commit 73bebd5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ export default class UnathenicatedControllers {

async getDoctors(req: Request, res: Response, next: NextFunction) {
try {
let offset = parseInt(req.query.offset as string);
let limit = parseInt(req.query.limit as string);
// let offset = parseInt(req.query.offset as string);
// let limit = parseInt(req.query.limit as string);

offset = isNaN(offset) || offset < 0 ? 0 : offset;
limit = isNaN(limit) || limit < 0 ? 10 : Math.min(limit, 100);
res.status(StatusCode.Success).json(await this.unauthenticatedUseCase.getDoctors(offset, limit))
// offset = isNaN(offset) || offset < 0 ? 0 : offset;
// limit = isNaN(limit) || limit < 0 ? 10 : Math.min(limit, 100);
res.status(StatusCode.Success).json(await this.unauthenticatedUseCase.getDoctors(0, 100))
} catch (error) {
next(error)
}
Expand Down
6 changes: 2 additions & 4 deletions server/src/use_case/UnauthenticatedUseCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import { PaginatedResult } from "../types";


export default class UnauthenticatedUseCases {
constructor(private doctorRepository: IDoctorRepository) { }


constructor(private doctorRepository: IDoctorRepository) {}

async getDoctors(offset: number, limit: number): Promise<PaginatedResult<IDoctor>> {
const isVerified = true;
const isBlocked = false
const data = await this.doctorRepository.findMany(offset, limit, isVerified, isBlocked);
data.items = data.items.filter(item=>item.role!=='admin')
data.items = data.items.filter(item => item.role !== 'admin')
return data;
}
}

0 comments on commit 73bebd5

Please sign in to comment.