Skip to content

Commit

Permalink
fix no restaurant found case (#77)
Browse files Browse the repository at this point in the history
Co-authored-by: NHT <[email protected]>
  • Loading branch information
nfesta2023 and hoangtuan910 authored Mar 15, 2024
1 parent 54f18dc commit c78267b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/feature/food/food.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export class FoodService {
} // end of getPriceRangeByMenuItem

async getFoodsWithListOfRestaurants(restaurantIds: number[]) {
if (!restaurantIds || restaurantIds.length === 0) {
return [];
}
const foodList = await this.menuItemRepo
.createQueryBuilder('menuItem')
.leftJoinAndSelect('menuItem.menuItemExt', 'menuItemExt')
Expand Down
4 changes: 3 additions & 1 deletion src/feature/recommendation/recommendation.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, HttpException } from '@nestjs/common';
import { Controller, HttpException, Logger } from '@nestjs/common';
import { RecommendationService } from './recommendation.service';
import { MessagePattern } from '@nestjs/microservices';
import { FoodRecommendationRequest } from './dto/food-recommendation-request.dto';
Expand All @@ -8,6 +8,7 @@ import { RestaurantRecommendationResponse } from './dto/restaurant-recommendatio

@Controller()
export class RecommendationController {
private readonly logger = new Logger(RecommendationController.name);
constructor(private readonly recommendationService: RecommendationService) {}

@MessagePattern({ cmd: 'get_general_food_recomendation' })
Expand All @@ -26,6 +27,7 @@ export class RecommendationController {
res.message = 'Get food recommendation successfully';
res.data = food;
} catch (error) {
this.logger.error(error);
if (error instanceof HttpException) {
res.statusCode = error.getStatus();
res.message = error.getResponse();
Expand Down

0 comments on commit c78267b

Please sign in to comment.