Skip to content

Commit

Permalink
Merge branch 'main' into feat/news-alerts
Browse files Browse the repository at this point in the history
# Conflicts:
#	server/api/tumdev/campus_backend.pb.go
#	server/api/tumdev/campus_backend.proto
#	server/api/tumdev/campus_backend.swagger.json
  • Loading branch information
CommanderStorm committed Sep 19, 2023
2 parents aaab3f8 + 2beabe1 commit e866866
Show file tree
Hide file tree
Showing 20 changed files with 2,530 additions and 1,940 deletions.
18 changes: 9 additions & 9 deletions client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ module github.com/TUM-Dev/Campus-Backend/client
go 1.21

require (
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20230913203125-6bbe13013fa5
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20230918233004-589371966806
github.com/sirupsen/logrus v1.9.3
google.golang.org/grpc v1.58.0
google.golang.org/grpc v1.58.1
google.golang.org/protobuf v1.31.0
)

require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.17.1 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
golang.org/x/net v0.15.0 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb // indirect
)
36 changes: 18 additions & 18 deletions client/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20230913203125-6bbe13013fa5 h1:/yMB5hJjFjEPB/HVP6wLTJWGqoCqQksXke+DiV2xUWY=
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20230913203125-6bbe13013fa5/go.mod h1:7XoRdXmxK852GxcyraiovgyS5z/eZ9wsofV9on7wvGQ=
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20230918233004-589371966806 h1:1Suxq24j2HNdQtS1cjbeEiFGpB8aXTZrdF6EdtUiu7E=
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20230918233004-589371966806/go.mod h1:fjoLL3rbdY6wTRJIksekT2p3OUp5ocFfXjB/avV/TVI=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -11,8 +11,8 @@ github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiu
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.17.1 h1:LSsiG61v9IzzxMkqEr6nrix4miJI62xlRjwT7BYD2SM=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.17.1/go.mod h1:Hbb13e3/WtqQ8U5hLGkek9gJvBLasHuPFI0UEGfnQ10=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 h1:RtRsiaGvWxcwd8y3BiRZxsylPT8hLWZ5SPcfI+3IDNk=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0/go.mod h1:TzP6duP4Py2pHLVPPQp42aoYI92+PCrVotyR5e8Vqlk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
Expand All @@ -21,22 +21,22 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 h1:L6iMMGrtzgHsWofoFcihmDEMYeDR9KN/ThbPWGrh++g=
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5/go.mod h1:oH/ZOT02u4kWEp7oYBGYFFkCdKS/uYR9Z7+0/xuuFp8=
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d h1:DoPTO70H+bcDXcd39vOqb2viZxgqeBeSGtZ55yZU4/Q=
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
google.golang.org/grpc v1.58.0 h1:32JY8YpPMSR45K+c3o6b8VL73V+rR8k+DeMIr4vRH8o=
google.golang.org/grpc v1.58.0/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb h1:XFBgcDwm7irdHTbz4Zk2h7Mh+eis4nfJEFQFYzJzuIA=
google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4=
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1:lK0oleSc7IQsUxO3U5TjL9DWlsxpEBemh+zpB7IqhWI=
google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb h1:Isk1sSH7bovx8Rti2wZK0UZF6oraBDK74uoyLEEVFN0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
google.golang.org/grpc v1.58.1 h1:OL+Vz23DTtrrldqHK49FUOPHyY75rvFqJfXC84NYW58=
google.golang.org/grpc v1.58.1/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
Expand Down
70 changes: 35 additions & 35 deletions client/localServer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
testImage = "./localServer/images/sampleimage.jpeg"
)

// main connects to a seperatly started local server and creates ratings for both, cafeterias and dishes.
// main connects to a seperatly started local server and creates ratings for both, canteens and dishes.
// Afterwards, they are queried and displayed on the console
func main() {
// Set up a connection to the local server.
Expand All @@ -38,7 +38,7 @@ func main() {

canteenHeadCount(c, ctx)

cafeteriaRatingTools(c, ctx)
canteenRatingTools(c, ctx)

}

Expand All @@ -54,28 +54,28 @@ func canteenHeadCount(c pb.CampusClient, ctx context.Context) {
}
}

func cafeteriaRatingTools(c pb.CampusClient, ctx context.Context) {
func canteenRatingTools(c pb.CampusClient, ctx context.Context) {

currentCafeteria := "MENSA_GARCHING"
currentCanteen := "MENSA_GARCHING"
currentDish := "Vegane rote Grütze mit Soja-Vanillesauce" //must be in the dish table
generateDishRating(c, ctx, currentCafeteria, currentDish, 3)
generateCafeteriaRating(c, ctx, currentCafeteria, 2)
queryCafeteria(currentCafeteria, c, ctx, true)
queryDish(currentCafeteria, currentDish, c, ctx, false)
generateCafeteriaRating(c, ctx, currentCafeteria, 2)
generateCafeteriaRating(c, ctx, currentCafeteria, 2)
generateDishRating(c, ctx, currentCafeteria, currentDish, 1)
generateDishRating(c, ctx, currentCanteen, currentDish, 3)
generateCanteenRating(c, ctx, currentCanteen, 2)
queryCanteen(currentCanteen, c, ctx, true)
queryDish(currentCanteen, currentDish, c, ctx, false)
generateCanteenRating(c, ctx, currentCanteen, 2)
generateCanteenRating(c, ctx, currentCanteen, 2)
generateDishRating(c, ctx, currentCanteen, currentDish, 1)

queryCafeteria(currentCafeteria, c, ctx, false)
queryDish(currentCafeteria, currentDish, c, ctx, false)
queryCanteen(currentCanteen, c, ctx, false)
queryDish(currentCanteen, currentDish, c, ctx, false)

}

func queryDish(cafeteria string, dish string, c pb.CampusClient, ctx context.Context, imageShouldBeStored bool) {
func queryDish(canteen string, dish string, c pb.CampusClient, ctx context.Context, imageShouldBeStored bool) {
res, err := c.GetDishRatings(ctx, &pb.DishRatingRequest{
Dish: dish,
CafeteriaId: cafeteria,
Limit: 3,
Dish: dish,
CanteenId: canteen,
Limit: 3,
})

if err != nil {
Expand Down Expand Up @@ -129,10 +129,10 @@ func queryDish(cafeteria string, dish string, c pb.CampusClient, ctx context.Con
}
}

func queryCafeteria(s string, c pb.CampusClient, ctx context.Context, imageShouldBeStored bool) {
res, err := c.GetCafeteriaRatings(ctx, &pb.CafeteriaRatingRequest{
CafeteriaId: s,
Limit: 3,
func queryCanteen(s string, c pb.CampusClient, ctx context.Context, imageShouldBeStored bool) {
res, err := c.GetCanteenRatings(ctx, &pb.CanteenRatingRequest{
CanteenId: s,
Limit: 3,
// From: timestamppb.New(time.Date(2022, 7, 8, 16, 0, 0, 0, time.Local)),
// To: timestamppb.New(time.Date(2022, 7, 8, 17, 0, 0, 0, time.Local)),
})
Expand Down Expand Up @@ -178,7 +178,7 @@ func queryCafeteria(s string, c pb.CampusClient, ctx context.Context, imageShoul
}
}

func generateCafeteriaRating(c pb.CampusClient, ctx context.Context, cafeteria string, rating int32) {
func generateCanteenRating(c pb.CampusClient, ctx context.Context, canteen string, rating int32) {
y := make([]*pb.RatingTag, 2)
y[0] = &pb.RatingTag{
Points: float64(1 + rating),
Expand All @@ -189,12 +189,12 @@ func generateCafeteriaRating(c pb.CampusClient, ctx context.Context, cafeteria s
TagId: 2,
}

_, err := c.NewCafeteriaRating(ctx, &pb.NewCafeteriaRatingRequest{
Points: rating,
CafeteriaId: cafeteria,
Comment: "Alles super, 2 Sterne",
RatingTags: y,
Image: getImageToBytes(testImage),
_, err := c.NewCanteenRating(ctx, &pb.NewCanteenRatingRequest{
Points: rating,
CanteenId: canteen,
Comment: "Alles super, 2 Sterne",
RatingTags: y,
Image: getImageToBytes(testImage),
})

if err != nil {
Expand All @@ -204,7 +204,7 @@ func generateCafeteriaRating(c pb.CampusClient, ctx context.Context, cafeteria s
}
}

func generateDishRating(c pb.CampusClient, ctx context.Context, cafeteria string, dish string, rating int32) {
func generateDishRating(c pb.CampusClient, ctx context.Context, canteen string, dish string, rating int32) {
y := make([]*pb.RatingTag, 3)
y[0] = &pb.RatingTag{
Points: float64(1 + rating),
Expand All @@ -220,12 +220,12 @@ func generateDishRating(c pb.CampusClient, ctx context.Context, cafeteria string
}

_, err := c.NewDishRating(ctx, &pb.NewDishRatingRequest{
Points: rating,
CafeteriaId: cafeteria,
Dish: dish,
Comment: "Alles Hähnchen",
RatingTags: y,
Image: getImageToBytes(testImage),
Points: rating,
CanteenId: canteen,
Dish: dish,
Comment: "Alles Hähnchen",
RatingTags: y,
Image: getImageToBytes(testImage),
})

if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions server/api/generate.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ rm -f google/api/*.go
rm -f google/api/*.swagger.json

echo maing sure that the generated files are formatted
go fmt tumdev/*.go
goimports -w tumdev/*.go
go fmt tumdev/*.go || exit 1
goimports -w tumdev/*.go || exit 1
buf format -w --path tumdev || exit 1

# clean up the stack
popd > /dev/null
Loading

0 comments on commit e866866

Please sign in to comment.