Skip to content

Commit

Permalink
fixed wrong naming
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Sep 18, 2023
1 parent 54f1cf8 commit 07cb675
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions server/backend/news.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
"google.golang.org/protobuf/types/known/emptypb"
)

func (s *CampusServer) GetNewsSources(ctx context.Context, _ *emptypb.Empty) (newsSources *pb.NewsSourceReply, err error) {
if err = s.checkDevice(ctx); err != nil {
return
func (s *CampusServer) GetNewsSources(ctx context.Context, _ *emptypb.Empty) (*pb.NewsSourceReply, error) {
if err := s.checkDevice(ctx); err != nil {
return nil, err
}

var sources []model.NewsSource
Expand All @@ -37,12 +37,12 @@ func (s *CampusServer) GetNewsSources(ctx context.Context, _ *emptypb.Empty) (ne
return &pb.NewsSourceReply{Sources: resp}, nil
}

func (s *CampusServer) GetNews(ctx context.Context, req *pb.GetNewsRequest) (newsSources *pb.GetNewsReply, err error) {
if err = s.checkDevice(ctx); err != nil {
return
func (s *CampusServer) GetNews(ctx context.Context, req *pb.GetNewsRequest) (*pb.GetNewsReply, error) {
if err := s.checkDevice(ctx); err != nil {
return nil, err
}

var sources []model.News
var newsEntries []model.News
// preloading files as the news images can be null
// I could not get outer joins to work => we are currently doing unnecessary db calls
tx := s.db.Preload("Files")
Expand All @@ -52,13 +52,13 @@ func (s *CampusServer) GetNews(ctx context.Context, req *pb.GetNewsRequest) (new
if req.LastNewsId != 0 {
tx = tx.Where("news > ?", req.LastNewsId)
}
if err := tx.Find(&sources).Error; err != nil {
if err := tx.Find(&newsEntries).Error; err != nil {
log.WithError(err).Error("could not find news item")
return nil, status.Error(codes.Internal, "could not GetNews")
}

resp := make([]*pb.NewsItem, len(sources))
for i, item := range sources {
resp := make([]*pb.NewsItem, len(newsEntries))
for i, item := range newsEntries {
log.WithField("title", item.Title).Trace("sending news")
resp[i] = &pb.NewsItem{
Id: item.News,
Expand Down

0 comments on commit 07cb675

Please sign in to comment.