mirror of https://github.com/statping/statping
parent
4327569bac
commit
b4a7eebe90
|
@ -0,0 +1,2 @@
|
||||||
|
# 0.90.12
|
||||||
|
- Fixed MySQL timestamp formatting. (issue #432)
|
|
@ -51,7 +51,7 @@ var (
|
||||||
ByAverage = func(column string, multiplier int) By {
|
ByAverage = func(column string, multiplier int) By {
|
||||||
switch database.DbType() {
|
switch database.DbType() {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
return By(fmt.Sprintf("CAST(AVG(%s) as UNSIGNED) as amount", column))
|
return By(fmt.Sprintf("CAST(AVG(%s) as UNSIGNED INT) as amount", column))
|
||||||
case "postgres":
|
case "postgres":
|
||||||
return By(fmt.Sprintf("cast(AVG(%s) as int) as amount", column))
|
return By(fmt.Sprintf("cast(AVG(%s) as int) as amount", column))
|
||||||
default:
|
default:
|
||||||
|
@ -71,7 +71,6 @@ func (t *TimeVar) ToValues() ([]*TimeValue, error) {
|
||||||
|
|
||||||
// GraphData will return all hits or failures
|
// GraphData will return all hits or failures
|
||||||
func (g *GroupQuery) GraphData(by By) ([]*TimeValue, error) {
|
func (g *GroupQuery) GraphData(by By) ([]*TimeValue, error) {
|
||||||
|
|
||||||
dbQuery := g.db.MultipleSelects(
|
dbQuery := g.db.MultipleSelects(
|
||||||
g.db.SelectByTime(g.Group),
|
g.db.SelectByTime(g.Group),
|
||||||
by.String(),
|
by.String(),
|
||||||
|
@ -98,16 +97,18 @@ func (g *GroupQuery) ToTimeValue() (*TimeVar, error) {
|
||||||
var data []*TimeValue
|
var data []*TimeValue
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var timeframe string
|
var timeframe string
|
||||||
amount := int64(0)
|
var amount int64
|
||||||
if err := rows.Scan(&timeframe, &amount); err != nil {
|
if err := rows.Scan(&timeframe, &amount); err != nil {
|
||||||
log.Error(err, timeframe)
|
log.Error(err, timeframe)
|
||||||
}
|
}
|
||||||
trueTime, _ := g.db.ParseTime(timeframe)
|
trueTime, _ := g.db.ParseTime(timeframe)
|
||||||
newTs := types.FixedTime(trueTime, g.Group)
|
newTs := types.FixedTime(trueTime, g.Group)
|
||||||
data = append(data, &TimeValue{
|
|
||||||
|
tv := &TimeValue{
|
||||||
Timeframe: newTs,
|
Timeframe: newTs,
|
||||||
Amount: amount,
|
Amount: amount,
|
||||||
})
|
}
|
||||||
|
data = append(data, tv)
|
||||||
}
|
}
|
||||||
return &TimeVar{g, data}, nil
|
return &TimeVar{g, data}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
log = utils.Log
|
log = utils.Log
|
||||||
removeRowsAfter = types.Month * 6
|
removeRowsAfter = types.Day * 90
|
||||||
maintenceDuration = types.Hour
|
maintenceDuration = types.Hour
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ type TimeGroup interface {
|
||||||
func (it *Db) ParseTime(t string) (time.Time, error) {
|
func (it *Db) ParseTime(t string) (time.Time, error) {
|
||||||
switch it.Type {
|
switch it.Type {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
return time.Parse("2006-01-02 15:04:05", t)
|
return time.Parse("2006-01-02T15:04:05Z", t)
|
||||||
case "postgres":
|
case "postgres":
|
||||||
return time.Parse("2006-01-02T15:04:05Z", t)
|
return time.Parse("2006-01-02T15:04:05Z", t)
|
||||||
default:
|
default:
|
||||||
|
@ -31,7 +31,7 @@ func (it *Db) FormatTime(t time.Time) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *Db) SelectByTime(increment time.Duration) string {
|
func (it *Db) SelectByTime(increment time.Duration) string {
|
||||||
seconds := int(increment.Seconds())
|
seconds := int64(increment.Seconds())
|
||||||
switch it.Type {
|
switch it.Type {
|
||||||
case "mysql":
|
case "mysql":
|
||||||
return fmt.Sprintf("FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(created_at) / %d) * %d) AS timeframe", seconds, seconds)
|
return fmt.Sprintf("FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(created_at) / %d) * %d) AS timeframe", seconds, seconds)
|
||||||
|
|
|
@ -8,6 +8,8 @@ services:
|
||||||
- 80:80
|
- 80:80
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/tmp/docker.sock:ro
|
- /var/run/docker.sock:/tmp/docker.sock:ro
|
||||||
|
networks:
|
||||||
|
- statping
|
||||||
|
|
||||||
# statping_dev:
|
# statping_dev:
|
||||||
# container_name: statping_dev
|
# container_name: statping_dev
|
||||||
|
|
|
@ -170,7 +170,7 @@
|
||||||
methods: {
|
methods: {
|
||||||
async chartHits(group) {
|
async chartHits(group) {
|
||||||
const start = this.nowSubtract(84600 * 3)
|
const start = this.nowSubtract(84600 * 3)
|
||||||
this.data = await Api.service_hits(this.service.id, this.toUnix(start), this.toUnix(new Date()), group, true)
|
this.data = await Api.service_hits(this.service.id, this.toUnix(start), this.toUnix(new Date()), group, false)
|
||||||
|
|
||||||
if (this.data.length === 0 && group !== "1h") {
|
if (this.data.length === 0 && group !== "1h") {
|
||||||
await this.chartHits("1h")
|
await this.chartHits("1h")
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Graphing {
|
||||||
}
|
}
|
||||||
|
|
||||||
async hits(service, days, group='24h') {
|
async hits(service, days, group='24h') {
|
||||||
const query = await API.service_hits(service.id, this.subtract(86400 * days), this.now(), group)
|
const query = await API.service_hits(service.id, this.subtract(86400 * days), this.now(), group, false)
|
||||||
let total = 0;
|
let total = 0;
|
||||||
let high = 0;
|
let high = 0;
|
||||||
let low = 99999999;
|
let low = 99999999;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.90.11
|
0.90.12
|
Loading…
Reference in New Issue