feat:#36 added new event grpc message

This commit is contained in:
Elmar Kresse
2024-06-18 12:50:21 +02:00
parent 56e77630b5
commit 08140b5802
14 changed files with 510 additions and 50 deletions

View File

@@ -33,6 +33,42 @@ func GetModuleWithEvents(module model.FeedModule, conn *grpc.ClientConn) (model.
}, nil
}
func GetModulesWithEvents(modules []model.FeedModule, conn *grpc.ClientConn) ([]model.Module, error) {
c := pb.NewModuleServiceClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
// List of uuids
uuids := make([]string, 0)
for _, module := range modules {
uuids = append(uuids, module.UUID)
}
r, err := c.GetModules(ctx, &pb.GetModulesRequest{Uuids: uuids})
if err != nil {
slog.Error("could not get modules: %v", "error", err)
}
moduleList := make([]model.Module, 0)
for _, module := range r.GetModules() {
events := make([]model.Event, 0)
for _, event := range module.Events {
events = append(events, protoToEvent(event))
}
moduleList = append(moduleList, model.Module{
UUID: module.Uuid,
Name: module.Name,
Prof: module.Prof,
Course: module.Course,
Semester: module.Semester,
Events: events,
})
}
return moduleList, nil
}
func protoToEvent(event *pb.Event) model.Event {
return model.Event{