From 93f9a0c39cf0fe3713c375bcfece848706794a5c Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Fri, 20 Nov 2015 03:10:24 -0800 Subject: [PATCH 1/3] Fixed created & updated columns in dashboard table --- pkg/models/dashboards.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/models/dashboards.go b/pkg/models/dashboards.go index 7d4a2690556..a07d6d1ee88 100644 --- a/pkg/models/dashboards.go +++ b/pkg/models/dashboards.go @@ -73,9 +73,12 @@ func NewDashboardFromJson(data map[string]interface{}) *Dashboard { if dash.Data["version"] != nil { dash.Version = int(dash.Data["version"].(float64)) + dash.Updated = time.Now() } } else { dash.Data["version"] = 0 + dash.Created = time.Now() + dash.Updated = time.Now() } return dash From ca01604b43d3585b98bd98d1db2ded8e9b3fce75 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Fri, 20 Nov 2015 04:37:24 -0800 Subject: [PATCH 2/3] Added statements in constructor --- pkg/models/dashboards.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkg/models/dashboards.go b/pkg/models/dashboards.go index a07d6d1ee88..1c6f2fad484 100644 --- a/pkg/models/dashboards.go +++ b/pkg/models/dashboards.go @@ -43,7 +43,9 @@ func NewDashboard(title string) *Dashboard { dash.Data = make(map[string]interface{}) dash.Data["title"] = title dash.Title = title - dash.UpdateSlug() + dash.Created = time.Now() + dash.Updated = time.Now() + dash.UpdateSlug() return dash } @@ -66,19 +68,19 @@ func NewDashboardFromJson(data map[string]interface{}) *Dashboard { dash := &Dashboard{} dash.Data = data dash.Title = dash.Data["title"].(string) - dash.UpdateSlug() + dash.UpdateSlug() if dash.Data["id"] != nil { dash.Id = int64(dash.Data["id"].(float64)) if dash.Data["version"] != nil { dash.Version = int(dash.Data["version"].(float64)) - dash.Updated = time.Now() - } + dash.Updated = time.Now() + } } else { dash.Data["version"] = 0 - dash.Created = time.Now() - dash.Updated = time.Now() + dash.Created = time.Now() + dash.Updated = time.Now() } return dash From 1b7f4f31ca39d68f16ab1003da6940732cb97ffb Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Fri, 20 Nov 2015 04:52:50 -0800 Subject: [PATCH 3/3] Tired of gofmt --- pkg/models/dashboards.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/models/dashboards.go b/pkg/models/dashboards.go index 1c6f2fad484..5b926c3e314 100644 --- a/pkg/models/dashboards.go +++ b/pkg/models/dashboards.go @@ -44,8 +44,8 @@ func NewDashboard(title string) *Dashboard { dash.Data["title"] = title dash.Title = title dash.Created = time.Now() - dash.Updated = time.Now() - dash.UpdateSlug() + dash.Updated = time.Now() + dash.UpdateSlug() return dash } @@ -68,19 +68,19 @@ func NewDashboardFromJson(data map[string]interface{}) *Dashboard { dash := &Dashboard{} dash.Data = data dash.Title = dash.Data["title"].(string) - dash.UpdateSlug() + dash.UpdateSlug() if dash.Data["id"] != nil { dash.Id = int64(dash.Data["id"].(float64)) if dash.Data["version"] != nil { dash.Version = int(dash.Data["version"].(float64)) - dash.Updated = time.Now() - } + dash.Updated = time.Now() + } } else { dash.Data["version"] = 0 - dash.Created = time.Now() - dash.Updated = time.Now() + dash.Created = time.Now() + dash.Updated = time.Now() } return dash