Skip to content

Commit

Permalink
fixed a few naming differences between Mensa and Cafeteria
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Mar 13, 2024
1 parent 8b7f232 commit 1f67c0b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
8 changes: 5 additions & 3 deletions server/api/tumdev/campus_backend.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions server/api/tumdev/campus_backend.proto
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ message ListCanteenRatingsReply {
message GetDishRatingsRequest {
// Mandatory Name of the canteen (EAT-API naming scheme "MENSA_GARCHING")
string canteen_id = 1;
// Mandatory Name of the dish (EAT-API naming scheme) Must be available int the given mensa
// Mandatory Name of the dish (EAT-API naming scheme)
// Must be available in the given cafeteria
string dish = 2;
// Optional Parameter to define an interval for the ratings (Lower bound)
google.protobuf.Timestamp from = 3;
Expand Down Expand Up @@ -323,9 +324,10 @@ message CreateDishRatingReply {}
message CreateDishRatingRequest {
// number in the range 1-5
int32 points = 1;
// Mandatory Name of the dish (EAT-API naming scheme "MENSA_GARCHING") Must be available int the given mensa
// Mandatory Name of the dish (EAT-API naming scheme "MENSA_GARCHING") Must be available in the given cafeteria
string canteen_id = 2;
// Mandatory Name of the dish (EAT-API naming scheme) Must be available int the given mensa
// Mandatory Name of the dish (EAT-API naming scheme)
// Must be available in the given cafeteria
string dish = 3;
// Optional JPEG image in Base64
bytes image = 4;
Expand Down
6 changes: 3 additions & 3 deletions server/api/tumdev/campus_backend.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1009,11 +1009,11 @@
},
"canteenId": {
"type": "string",
"title": "Mandatory Name of the dish (EAT-API naming scheme \"MENSA_GARCHING\") Must be available int the given mensa"
"title": "Mandatory Name of the dish (EAT-API naming scheme \"MENSA_GARCHING\") Must be available in the given cafeteria"
},
"dish": {
"type": "string",
"title": "Mandatory Name of the dish (EAT-API naming scheme) Must be available int the given mensa"
"title": "Mandatory Name of the dish (EAT-API naming scheme)\nMust be available in the given cafeteria"
},
"image": {
"type": "string",
Expand Down Expand Up @@ -1135,7 +1135,7 @@
},
"dish": {
"type": "string",
"title": "Mandatory Name of the dish (EAT-API naming scheme) Must be available int the given mensa"
"title": "Mandatory Name of the dish (EAT-API naming scheme)\nMust be available in the given cafeteria"
},
"from": {
"type": "string",
Expand Down
14 changes: 7 additions & 7 deletions server/backend/cafeteria.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,27 +400,27 @@ func (s *CampusServer) CreateDishRating(ctx context.Context, input *pb.CreateDis
return nil, errorRes
}

var dishInMensa *model.Dish
if err := tx.First(&dishInMensa, "name LIKE ? AND cafeteriaID = ?", input.Dish, cafeteriaID).Error; err != nil || dishInMensa == nil {
log.WithError(err).Error("Error while creating a new dishInMensa rating.")
var dishInCafeteria *model.Dish
if err := tx.First(&dishInCafeteria, "name LIKE ? AND cafeteriaID = ?", input.Dish, cafeteriaID).Error; err != nil || dishInCafeteria == nil {
log.WithError(err).Error("Error while creating a new dishInCafeteria rating.")
return nil, status.Error(codes.InvalidArgument, "Dish is not offered in this week in this canteen. Rating has not been saved.")
}

resPath := imageWrapper(input.Image, "dishes", dishInMensa.Dish)
resPath := imageWrapper(input.Image, "dishes", dishInCafeteria.Dish)

rating := model.DishRating{
Comment: input.Comment,
DishID: dishInMensa.Dish,
DishID: dishInCafeteria.Dish,
Points: input.Points,
Timestamp: time.Now(),
Image: resPath,
}
if err := tx.Create(&rating).Error; err != nil {
log.WithError(err).Error("while creating a new dishInMensa rating.")
log.WithError(err).Error("while creating a new dishInCafeteria rating.")
return nil, status.Error(codes.Internal, "Error while creating the new rating in the database. Rating has not been saved.")
}

assignDishNameTag(rating, dishInMensa.Dish, tx)
assignDishNameTag(rating, dishInCafeteria.Dish, tx)

if err := storeRatingTags(rating.DishRating, input.RatingTags, DISH, tx); err != nil {
return &pb.CreateDishRatingReply{}, err
Expand Down

0 comments on commit 1f67c0b

Please sign in to comment.