Skip to content

Commit

Permalink
Addressed Mateo's comment of filterByPrice
Browse files Browse the repository at this point in the history
  • Loading branch information
akmatchev committed Sep 20, 2023
1 parent dc8ffc1 commit ab9db56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/repositories/PostRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export class PostRepository extends AbstractRepository<PostModel> {
return await this.repository
.createQueryBuilder("post")
.leftJoinAndSelect("post.user", "user")
.where("post.original_price >= :lowerBound", {lowerBound: lowerBound})
.andWhere("post.original_price <= :upperBound", {upperBound: upperBound})
.where("CASE WHEN post.altered_price = -1 THEN post.original_price ELSE post.altered_price END >= :lowerBound", { lowerBound: lowerBound })
.andWhere("CASE WHEN post.altered_price = -1 THEN post.original_price ELSE post.altered_price END <= :upperBound", { upperBound: upperBound })
.andWhere("post.archive = false")
.getMany();
}
Expand All @@ -123,7 +123,7 @@ export class PostRepository extends AbstractRepository<PostModel> {
return await this.repository.save(post)
}

public async editPostPrice(post: PostModel, new_price: number) : Promise<PostModel> {
public async editPostPrice(post: PostModel, new_price: number): Promise<PostModel> {
post.altered_price = new_price
return await this.repository.save(post)
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class UserService {
}

public async getAllUsers(user: UserModel): Promise<UserModel[]> {
// if (!user.admin) throw new UnauthorizedError('User does not have permission to get all users')
if (!user.admin) throw new UnauthorizedError('User does not have permission to get all users')
return this.transactions.readOnly(async (transactionalEntityManager) => {
const userRepository = Repositories.user(transactionalEntityManager);
return userRepository.getAllUsers();
Expand Down

0 comments on commit ab9db56

Please sign in to comment.