mirror of https://github.com/statping/statping
testing
parent
bede064e57
commit
514dcff4be
|
@ -4,7 +4,7 @@ os:
|
||||||
language: go
|
language: go
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- "1.10.3"
|
- "1.11"
|
||||||
|
|
||||||
go_import_path: github.com/hunterlong/statup
|
go_import_path: github.com/hunterlong/statup
|
||||||
|
|
||||||
|
|
|
@ -296,18 +296,18 @@
|
||||||
"md4",
|
"md4",
|
||||||
]
|
]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "0e37d006457bf46f9e6692014ba72ef82c33022c"
|
revision = "e3636079e1a4c1f337f212cc5cd2aca108f6c900"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:6fb1dd382722f93fcf7c52ff631f7b899d8c5d54314d88d42dd1f4e5ac404a30"
|
digest = "1:6f82ed211591ecb407897ca46ff6149d618223088aecad72675804f106033629"
|
||||||
name = "golang.org/x/sys"
|
name = "golang.org/x/sys"
|
||||||
packages = [
|
packages = [
|
||||||
"unix",
|
"unix",
|
||||||
"windows",
|
"windows",
|
||||||
]
|
]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "c2ed4eda69e7f62900806e4cd6e45f0429f859fa"
|
revision = "e4b3c5e9061176387e7cea65e4dc5853801f3fb7"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:c25289f43ac4a68d88b02245742347c94f1e108c534dda442188015ff80669b3"
|
digest = "1:c25289f43ac4a68d88b02245742347c94f1e108c534dda442188015ff80669b3"
|
||||||
|
|
|
@ -47,14 +47,6 @@ func FindCheckin(api string) *types.Checkin {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) AllCheckins() []*types.Checkin {
|
|
||||||
var checkins []*types.Checkin
|
|
||||||
col := checkinDB().Where("service = ?", s.Id).Order("id desc")
|
|
||||||
col.Find(&checkins)
|
|
||||||
s.Checkins = checkins
|
|
||||||
return checkins
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *Checkin) Create() (int64, error) {
|
func (u *Checkin) Create() (int64, error) {
|
||||||
u.CreatedAt = time.Now()
|
u.CreatedAt = time.Now()
|
||||||
row := checkinDB().Create(u)
|
row := checkinDB().Create(u)
|
||||||
|
|
|
@ -69,7 +69,7 @@ func checkinDB() *gorm.DB {
|
||||||
// HitsBetween returns the gorm database query for a collection of service hits between a time range
|
// HitsBetween returns the gorm database query for a collection of service hits between a time range
|
||||||
func (s *Service) HitsBetween(t1, t2 time.Time, group string) *gorm.DB {
|
func (s *Service) HitsBetween(t1, t2 time.Time, group string) *gorm.DB {
|
||||||
selector := Dbtimestamp(group)
|
selector := Dbtimestamp(group)
|
||||||
return DbSession.Debug().Model(&types.Hit{}).Select(selector).Where("service = ? AND created_at BETWEEN ? AND ?", s.Id, t1.Format(types.TIME_DAY), t2.Format(types.TIME_DAY)).Order("timeframe asc", false).Group("timeframe")
|
return DbSession.Model(&types.Hit{}).Select(selector).Where("service = ? AND created_at BETWEEN ? AND ?", s.Id, t1.Format(types.TIME_DAY), t2.Format(types.TIME_DAY)).Order("timeframe asc", false).Group("timeframe")
|
||||||
}
|
}
|
||||||
|
|
||||||
func CloseDB() {
|
func CloseDB() {
|
||||||
|
|
|
@ -49,6 +49,12 @@ func SelectService(id int64) *Service {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Service) Checkins() []*types.Checkin {
|
||||||
|
var hits []*types.Checkin
|
||||||
|
servicesDB().Where("service = ?", s.Id).Scan(&hits)
|
||||||
|
return hits
|
||||||
|
}
|
||||||
|
|
||||||
// SelectAllServices returns a slice of *core.Service to be store on []*core.Services, should only be called once on startup.
|
// SelectAllServices returns a slice of *core.Service to be store on []*core.Services, should only be called once on startup.
|
||||||
func (c *Core) SelectAllServices() ([]*Service, error) {
|
func (c *Core) SelectAllServices() ([]*Service, error) {
|
||||||
var services []*Service
|
var services []*Service
|
||||||
|
@ -60,7 +66,7 @@ func (c *Core) SelectAllServices() ([]*Service, error) {
|
||||||
CoreApp.Services = nil
|
CoreApp.Services = nil
|
||||||
for _, service := range services {
|
for _, service := range services {
|
||||||
service.Start()
|
service.Start()
|
||||||
service.AllCheckins()
|
service.Checkins()
|
||||||
service.AllFailures()
|
service.AllFailures()
|
||||||
CoreApp.Services = append(CoreApp.Services, service)
|
CoreApp.Services = append(CoreApp.Services, service)
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ type ServiceInterface interface {
|
||||||
Create(bool) (int64, error)
|
Create(bool) (int64, error)
|
||||||
Update(bool) error
|
Update(bool) error
|
||||||
Delete() error
|
Delete() error
|
||||||
|
Checkins() []*Checkin
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start will create a channel for the service checking go routine
|
// Start will create a channel for the service checking go routine
|
||||||
|
|
Loading…
Reference in New Issue