mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-08-07 12:19:14 +02:00
feat:#36 added new event grpc message
This commit is contained in:
@@ -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{
|
||||
|
Reference in New Issue
Block a user