Procházet zdrojové kódy

Merge pull request #3297 from utkarshcmu/db-update

Fixed created & updated columns update in dashboard table
Torkel Ödegaard před 10 roky
rodič
revize
fc78e42a78
1 změnil soubory, kde provedl 5 přidání a 0 odebrání
  1. 5 0
      pkg/models/dashboards.go

+ 5 - 0
pkg/models/dashboards.go

@@ -43,6 +43,8 @@ func NewDashboard(title string) *Dashboard {
 	dash.Data = make(map[string]interface{})
 	dash.Data["title"] = title
 	dash.Title = title
+	dash.Created = time.Now()
+	dash.Updated = time.Now()
 	dash.UpdateSlug()
 	return dash
 }
@@ -73,9 +75,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