fix issue with not found services

This commit is contained in:
pluja 2024-02-25 17:22:55 +01:00
parent 8863f11bcf
commit 9f561e0702

View File

@ -70,6 +70,7 @@ func (p *PbClient) GetServiceByNameOrUrl(id string) (*Service, error) {
return nil, err return nil, err
} }
if len(response.Items) > 0 {
service := response.Items[0] service := response.Items[0]
// Sort attributes by rating // Sort attributes by rating
@ -82,8 +83,11 @@ func (p *PbClient) GetServiceByNameOrUrl(id string) (*Service, error) {
} }
return ratingOrder[service.Expand["attributes"][i].Rating] > ratingOrder[service.Expand["attributes"][j].Rating] return ratingOrder[service.Expand["attributes"][i].Rating] > ratingOrder[service.Expand["attributes"][j].Rating]
}) })
return &service, nil return &service, nil
} else {
return nil, fmt.Errorf("Service not found.")
}
} }
func (p *PbClient) GetServiceById(id string) (*Service, error) { func (p *PbClient) GetServiceById(id string) (*Service, error) {