statping/types/groups/methods.go

20 lines
568 B
Go
Raw Normal View History

2020-03-04 10:29:00 +00:00
package groups
import (
2020-03-09 18:17:55 +00:00
"github.com/statping/statping/types/services"
2020-03-04 10:29:00 +00:00
)
func (g *Group) Services() []*services.Service {
var services []*services.Service
2020-03-10 05:24:35 +00:00
db.Where("group = ?", g.Id).Find(&services)
2020-03-04 10:29:00 +00:00
return services
}
// GroupOrder will reorder the groups based on 'order_id' (Order)
type GroupOrder []*Group
// Sort interface for resorting the Groups in order
func (c GroupOrder) Len() int { return len(c) }
func (c GroupOrder) Swap(i, j int) { c[i], c[j] = c[j], c[i] }
func (c GroupOrder) Less(i, j int) bool { return c[i].Order < c[j].Order }