diff --git a/CHANGELOG.md b/CHANGELOG.md index 67d0f969..79e15210 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Added Help page that is generated from Statping's Wiki repo on build - Modified Service Group failures on index page to show 90 days of failures - Modified Service view page, updated Latency and Ping charts, added failures below +- Modified Service chart on index page to show ping data along with latency # 0.90.63 (08-17-2020) - Modified build process to use xgo for all arch builds diff --git a/database/grouping.go b/database/grouping.go index 8ae3fd1f..d140b86c 100644 --- a/database/grouping.go +++ b/database/grouping.go @@ -87,6 +87,9 @@ func (g *GroupQuery) GraphData(by By) ([]*TimeValue, error) { return caller.ToValues() } +// ToTimeValue will format the SQL rows into a JSON format for the API. +// [{"timestamp": "2006-01-02T15:04:05Z", "amount": 468293}] +// TODO redo this entire function, use better SQL query to group by time func (g *GroupQuery) ToTimeValue() (*TimeVar, error) { rows, err := g.db.Rows() if err != nil { diff --git a/database/time.go b/database/time.go index ea41f77d..db690bab 100644 --- a/database/time.go +++ b/database/time.go @@ -19,10 +19,9 @@ func (it *Db) ParseTime(t string) (time.Time, error) { } } +// FormatTime returns the timestamp in the same format as the DATETIME column in database func (it *Db) FormatTime(t time.Time) string { switch it.Type { - case "mysql": - return t.Format("2006-01-02 15:04:05") case "postgres": return t.Format("2006-01-02 15:04:05.999999999") default: @@ -30,6 +29,7 @@ func (it *Db) FormatTime(t time.Time) string { } } +// SelectByTime returns an SQL query that will group "created_at" column by x seconds and returns as "timeframe" func (it *Db) SelectByTime(increment time.Duration) string { seconds := int64(increment.Seconds()) switch it.Type { @@ -41,33 +41,3 @@ func (it *Db) SelectByTime(increment time.Duration) string { return fmt.Sprintf("datetime((strftime('%%s', created_at) / %d) * %d, 'unixepoch') as timeframe", seconds, seconds) } } - -func (it *Db) correctTimestamp(increment string) string { - var timestamper string - switch increment { - case "second": - timestamper = "%Y-%m-%d %H:%M:%S" - case "minute": - timestamper = "%Y-%m-%d %H:%M:00" - case "hour": - timestamper = "%Y-%m-%d %H:00:00" - case "day": - timestamper = "%Y-%m-%d 00:00:00" - case "month": - timestamper = "%Y-%m-01 00:00:00" - case "year": - timestamper = "%Y-01-01 00:00:00" - default: - timestamper = "%Y-%m-%d 00:00:00" - } - - switch it.Type { - case "mysql": - case "second": - timestamper = "%Y-%m-%d %H:%i:%S" - case "minute": - timestamper = "%Y-%m-%d %H:%i:00" - } - - return timestamper -} diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 999cd1b4..afa27a8c 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,6 +1,6 @@ diff --git a/frontend/src/components/Dashboard/TopNav.vue b/frontend/src/components/Dashboard/TopNav.vue index 9ea2ee5c..42e8bf71 100644 --- a/frontend/src/components/Dashboard/TopNav.vue +++ b/frontend/src/components/Dashboard/TopNav.vue @@ -65,7 +65,3 @@ } } - - - diff --git a/frontend/src/components/Index/Group.vue b/frontend/src/components/Index/Group.vue index 1224dd0e..b6aa8791 100644 --- a/frontend/src/components/Index/Group.vue +++ b/frontend/src/components/Index/Group.vue @@ -1,9 +1,9 @@