Skip to content

Commit

Permalink
Canteen Batch Logging Silencing (#254)
Browse files Browse the repository at this point in the history
* move head count to canteen service

* silence logging for batch db operations

* renamed cafeteria service to cafeteria

* Update server/backend/cafeteria_rating_db_initializer.go

Co-authored-by: Frank Elsinga <[email protected]>

* Update server/backend/cafeteria_rating_db_initializer.go

Co-authored-by: Frank Elsinga <[email protected]>

* code review feedback

---------

Co-authored-by: Frank Elsinga <[email protected]>
  • Loading branch information
tobiasjungmann and CommanderStorm authored Oct 6, 2023
1 parent 53c94cf commit ea68230
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -729,3 +729,20 @@ func (s *CampusServer) ListDishes(ctx context.Context, request *pb.ListDishesReq
Dish: results,
}, requestStatus
}

// GetCanteenHeadCount RPC Endpoint
func (s *CampusServer) GetCanteenHeadCount(ctx context.Context, input *pb.GetCanteenHeadCountRequest) (*pb.GetCanteenHeadCountReply, error) {
data := model.CanteenHeadCount{Count: 0, MaxCount: 0, Percent: -1} // Initialize with an empty (not found) value
err := s.db.WithContext(ctx).Where(model.CanteenHeadCount{CanteenId: input.CanteenId}).FirstOrInit(&data).Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
log.WithError(err).Error("while querying the canteen head count for: ", input.CanteenId)
return nil, status.Error(codes.Internal, "failed to query head count")
}

return &pb.GetCanteenHeadCountReply{
Count: data.Count,
MaxCount: data.MaxCount,
Percent: data.Percent,
Timestamp: timestamppb.New(data.Timestamp),
}, nil
}
29 changes: 0 additions & 29 deletions server/backend/canteen_head_count.go

This file was deleted.

0 comments on commit ea68230

Please sign in to comment.