feat: add universities and restaurants
This commit is contained in:
31
core/handler/universities/shared.go
Normal file
31
core/handler/universities/shared.go
Normal file
@ -0,0 +1,31 @@
|
||||
package universities
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.bissendorf.co/bissendorf/unifood/m/v2/core/interfaces"
|
||||
"git.bissendorf.co/bissendorf/unifood/m/v2/model/external/stwbremen"
|
||||
"git.bissendorf.co/bissendorf/unifood/m/v2/util"
|
||||
)
|
||||
|
||||
func getRestaurantList(ctx context.Context, client interfaces.QueryClient[stwbremen.RestaurantList]) ([]string, error) {
|
||||
list, err := client.Get(ctx,
|
||||
`page('essen-und-trinken')`,
|
||||
`{"items": "page.children.children"}`,
|
||||
false,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load university list: %w", err)
|
||||
}
|
||||
|
||||
return util.Transform(list.Items, func(i *string) string {
|
||||
parts := strings.SplitN(*i, "/", 2)
|
||||
if len(parts) < 2 {
|
||||
return parts[0]
|
||||
}
|
||||
|
||||
return parts[1]
|
||||
}), nil
|
||||
}
|
||||
Reference in New Issue
Block a user