Skip to content

Commit

Permalink
added date to the GetNews endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Sep 19, 2023
1 parent aae98ca commit a191059
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 100 deletions.
2 changes: 1 addition & 1 deletion client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/TUM-Dev/Campus-Backend/client
go 1.21

require (
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20230919162132-71bec88330f7
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20230919222217-aae98ca6718a
github.com/sirupsen/logrus v1.9.3
google.golang.org/grpc v1.58.1
)
Expand Down
4 changes: 2 additions & 2 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-20230919162132-71bec88330f7 h1:TDgiN5Z1vi3V0Qo94MIXURiD9+U7TGiRtiUIqN/rulo=
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20230919162132-71bec88330f7/go.mod h1:fjoLL3rbdY6wTRJIksekT2p3OUp5ocFfXjB/avV/TVI=
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20230919222217-aae98ca6718a h1:liiUwphQFYkB0DeDCOX3iasHwgcUSQxEEYDohpurAI0=
github.com/TUM-Dev/Campus-Backend/server v0.0.0-20230919222217-aae98ca6718a/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 Down
202 changes: 107 additions & 95 deletions server/api/tumdev/campus_backend.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions server/api/tumdev/campus_backend.proto
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ message News {
string image_url = 5;
string source = 6;
google.protobuf.Timestamp created = 7;
google.protobuf.Timestamp date = 8;
}

message GetNewsReply {
Expand Down
4 changes: 4 additions & 0 deletions server/api/tumdev/campus_backend.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1586,6 +1586,10 @@
"created": {
"type": "string",
"format": "date-time"
},
"date": {
"type": "string",
"format": "date-time"
}
}
},
Expand Down
1 change: 1 addition & 0 deletions server/backend/news.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (s *CampusServer) GetNews(ctx context.Context, req *pb.GetNewsRequest) (*pb
ImageUrl: item.Image.String,
Source: fmt.Sprintf("%d", item.Src),
Created: timestamppb.New(item.Created),
Date: timestamppb.New(item.Date),
}
}
return &pb.GetNewsReply{News: resp}, nil
Expand Down
4 changes: 2 additions & 2 deletions server/backend/news_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ func (s *NewsSuite) Test_GetNewsMultiple() {
require.NoError(s.T(), err)
expectedResp := &pb.GetNewsReply{
News: []*pb.News{
{Id: n1.News, Title: n1.Title, Text: n1.Description, Link: n1.Link, ImageUrl: n1.Image.String, Source: fmt.Sprintf("%d", n1.Src), Created: timestamppb.New(n1.Created)},
{Id: n2.News, Title: n2.Title, Text: n2.Description, Link: n2.Link, ImageUrl: n2.Image.String, Source: fmt.Sprintf("%d", n2.Src), Created: timestamppb.New(n2.Created)},
{Id: n1.News, Title: n1.Title, Text: n1.Description, Link: n1.Link, ImageUrl: n1.Image.String, Source: fmt.Sprintf("%d", n1.Src), Created: timestamppb.New(n1.Created), Date: timestamppb.New(n1.Date)},
{Id: n2.News, Title: n2.Title, Text: n2.Description, Link: n2.Link, ImageUrl: n2.Image.String, Source: fmt.Sprintf("%d", n2.Src), Created: timestamppb.New(n2.Created), Date: timestamppb.New(n2.Date)},
},
}
require.Equal(s.T(), expectedResp, response)
Expand Down

0 comments on commit a191059

Please sign in to comment.