mirror of https://github.com/statping/statping
Merge pull request #221 from viartemev/fix-github-220
Fix github-issue-220: Incorrect query to Pgpull/219/head
commit
85b4129b08
|
@ -101,8 +101,7 @@ func incidentsUpdatesDB() *gorm.DB {
|
||||||
func (s *Service) HitsBetween(t1, t2 time.Time, group string, column string) *gorm.DB {
|
func (s *Service) HitsBetween(t1, t2 time.Time, group string, column string) *gorm.DB {
|
||||||
selector := Dbtimestamp(group, column)
|
selector := Dbtimestamp(group, column)
|
||||||
if CoreApp.DbConnection == "postgres" {
|
if CoreApp.DbConnection == "postgres" {
|
||||||
timeQuery := fmt.Sprintf("service = %v AND created_at BETWEEN '%v.000000' AND '%v.000000'", s.Id, t1.UTC().Format(types.POSTGRES_TIME), t2.UTC().Format(types.POSTGRES_TIME))
|
return hitsDB().Select(selector).Where("service = ? AND created_at BETWEEN ? AND ?", s.Id, t1.UTC().Format(types.TIME), t2.UTC().Format(types.TIME))
|
||||||
return hitsDB().Select(selector).Where(timeQuery)
|
|
||||||
} else {
|
} else {
|
||||||
return hitsDB().Select(selector).Where("service = ? AND created_at BETWEEN ? AND ?", s.Id, t1.UTC().Format(types.TIME_DAY), t2.UTC().Format(types.TIME_DAY))
|
return hitsDB().Select(selector).Where("service = ? AND created_at BETWEEN ? AND ?", s.Id, t1.UTC().Format(types.TIME_DAY), t2.UTC().Format(types.TIME_DAY))
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import (
|
||||||
const (
|
const (
|
||||||
TIME_NANO = "2006-01-02T15:04:05Z"
|
TIME_NANO = "2006-01-02T15:04:05Z"
|
||||||
TIME = "2006-01-02 15:04:05"
|
TIME = "2006-01-02 15:04:05"
|
||||||
POSTGRES_TIME = "2006-01-02 15:04"
|
|
||||||
CHART_TIME = "2006-01-02T15:04:05.999999-07:00"
|
CHART_TIME = "2006-01-02T15:04:05.999999-07:00"
|
||||||
TIME_DAY = "2006-01-02"
|
TIME_DAY = "2006-01-02"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue