Commit ca33812c authored by =Corey Hulen's avatar =Corey Hulen

PLT-7 adding loc db calls for system table

parent f5eb3c1b
......@@ -92,14 +92,14 @@ func main() {
}
func setDiagnosticId() {
if result := <-api.Srv.Store.System().Get(); result.Err == nil {
if result := <-api.Srv.Store.System().Get(utils.T); result.Err == nil {
props := result.Data.(model.StringMap)
id := props[model.SYSTEM_DIAGNOSTIC_ID]
if len(id) == 0 {
id = model.NewId()
systemId := &model.System{Name: model.SYSTEM_DIAGNOSTIC_ID, Value: id}
<-api.Srv.Store.System().Save(systemId)
<-api.Srv.Store.System().Save(utils.T, systemId)
}
utils.CfgDiagnosticId = id
......@@ -110,7 +110,7 @@ func runSecurityAndDiagnosticsJobAndForget() {
go func() {
for {
if *utils.Cfg.ServiceSettings.EnableSecurityFixAlert {
if result := <-api.Srv.Store.System().Get(); result.Err == nil {
if result := <-api.Srv.Store.System().Get(utils.T); result.Err == nil {
props := result.Data.(model.StringMap)
lastSecurityTime, _ := strconv.ParseInt(props[model.SYSTEM_LAST_SECURITY_TIME], 10, 0)
currentTime := model.GetMillis()
......@@ -135,9 +135,9 @@ func runSecurityAndDiagnosticsJobAndForget() {
systemSecurityLastTime := &model.System{Name: model.SYSTEM_LAST_SECURITY_TIME, Value: strconv.FormatInt(currentTime, 10)}
if lastSecurityTime == 0 {
<-api.Srv.Store.System().Save(systemSecurityLastTime)
<-api.Srv.Store.System().Save(utils.T, systemSecurityLastTime)
} else {
<-api.Srv.Store.System().Update(systemSecurityLastTime)
<-api.Srv.Store.System().Update(utils.T, systemSecurityLastTime)
}
if ucr := <-api.Srv.Store.User().GetTotalUsersCount(); ucr.Err == nil {
......@@ -185,7 +185,7 @@ func runSecurityAndDiagnosticsJobAndForget() {
}
bulletinSeen := &model.System{Name: "SecurityBulletin_" + bulletin.Id, Value: bulletin.Id}
<-api.Srv.Store.System().Save(bulletinSeen)
<-api.Srv.Store.System().Save(utils.T, bulletinSeen)
}
}
}
......
......@@ -151,12 +151,12 @@ func NewSqlStore() Store {
sqlStore.preference.(*SqlPreferenceStore).DeleteUnusedFeatures(utils.T)
if model.IsPreviousVersion(schemaVersion) || isSchemaVersion07 || isSchemaVersion10 {
sqlStore.system.Update(&model.System{Name: "Version", Value: model.CurrentVersion})
sqlStore.system.Update(utils.T, &model.System{Name: "Version", Value: model.CurrentVersion})
l4g.Warn("The database schema has been upgraded to version " + model.CurrentVersion)
}
if schemaVersion == "" {
sqlStore.system.Save(&model.System{Name: "Version", Value: model.CurrentVersion})
sqlStore.system.Save(utils.T, &model.System{Name: "Version", Value: model.CurrentVersion})
l4g.Info("The database schema has been set to version " + model.CurrentVersion)
}
......@@ -210,12 +210,12 @@ func (ss SqlStore) GetCurrentSchemaVersion() string {
}
func (ss SqlStore) MarkSystemRanUnitTests() {
if result := <-ss.System().Get(); result.Err == nil {
if result := <-ss.System().Get(utils.T); result.Err == nil {
props := result.Data.(model.StringMap)
unitTests := props[model.SYSTEM_RAN_UNIT_TESTS]
if len(unitTests) == 0 {
systemTests := &model.System{Name: model.SYSTEM_RAN_UNIT_TESTS, Value: "1"}
<-ss.System().Save(systemTests)
<-ss.System().Save(utils.T, systemTests)
}
}
}
......
......@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
goi18n "github.com/nicksnyder/go-i18n/i18n"
)
type SqlSystemStore struct {
......@@ -29,7 +30,7 @@ func (s SqlSystemStore) UpgradeSchemaIfNeeded() {
func (s SqlSystemStore) CreateIndexesIfNotExists() {
}
func (s SqlSystemStore) Save(system *model.System) StoreChannel {
func (s SqlSystemStore) Save(T goi18n.TranslateFunc, system *model.System) StoreChannel {
storeChannel := make(StoreChannel)
......@@ -47,7 +48,7 @@ func (s SqlSystemStore) Save(system *model.System) StoreChannel {
return storeChannel
}
func (s SqlSystemStore) Update(system *model.System) StoreChannel {
func (s SqlSystemStore) Update(T goi18n.TranslateFunc, system *model.System) StoreChannel {
storeChannel := make(StoreChannel)
......@@ -65,7 +66,7 @@ func (s SqlSystemStore) Update(system *model.System) StoreChannel {
return storeChannel
}
func (s SqlSystemStore) Get() StoreChannel {
func (s SqlSystemStore) Get(T goi18n.TranslateFunc) StoreChannel {
storeChannel := make(StoreChannel)
......
......@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
"testing"
)
......@@ -12,9 +13,9 @@ func TestSqlSystemStore(t *testing.T) {
Setup()
system := &model.System{Name: model.NewId(), Value: "value"}
Must(store.System().Save(system))
Must(store.System().Save(utils.T, system))
result := <-store.System().Get()
result := <-store.System().Get(utils.T)
systems := result.Data.(model.StringMap)
if systems[system.Name] != system.Value {
......@@ -22,9 +23,9 @@ func TestSqlSystemStore(t *testing.T) {
}
system.Value = "value2"
Must(store.System().Update(system))
Must(store.System().Update(utils.T, system))
result2 := <-store.System().Get()
result2 := <-store.System().Get(utils.T)
systems2 := result2.Data.(model.StringMap)
if systems2[system.Name] != system.Value {
......
......@@ -162,9 +162,9 @@ type OAuthStore interface {
}
type SystemStore interface {
Save(system *model.System) StoreChannel
Update(system *model.System) StoreChannel
Get() StoreChannel
Save(T goi18n.TranslateFunc, system *model.System) StoreChannel
Update(T goi18n.TranslateFunc, system *model.System) StoreChannel
Get(T goi18n.TranslateFunc) StoreChannel
}
type WebhookStore interface {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment