mirror of
https://codeberg.org/pluja/kycnot.me
synced 2025-01-22 12:21:11 -05:00
fix issue with not found services
This commit is contained in:
parent
8863f11bcf
commit
9f561e0702
@ -70,20 +70,24 @@ func (p *PbClient) GetServiceByNameOrUrl(id string) (*Service, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
service := response.Items[0]
|
if len(response.Items) > 0 {
|
||||||
|
service := response.Items[0]
|
||||||
|
|
||||||
// Sort attributes by rating
|
// Sort attributes by rating
|
||||||
sort.SliceStable(service.Expand["attributes"], func(i, j int) bool {
|
sort.SliceStable(service.Expand["attributes"], func(i, j int) bool {
|
||||||
ratingOrder := map[string]int{
|
ratingOrder := map[string]int{
|
||||||
"bad": 4,
|
"bad": 4,
|
||||||
"warn": 3,
|
"warn": 3,
|
||||||
"good": 2,
|
"good": 2,
|
||||||
"info": 1,
|
"info": 1,
|
||||||
}
|
}
|
||||||
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
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("Service not found.")
|
||||||
|
}
|
||||||
|
|
||||||
return &service, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PbClient) GetServiceById(id string) (*Service, error) {
|
func (p *PbClient) GetServiceById(id string) (*Service, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user