fix: 优化数据看板更新逻辑

This commit is contained in:
CaIon 2024-01-07 18:33:41 +08:00
parent bf8794d257
commit ce05e7dd86
2 changed files with 10 additions and 7 deletions

View File

@ -67,9 +67,10 @@ func main() {
go model.SyncOptions(common.SyncFrequency)
go model.SyncChannelCache(common.SyncFrequency)
}
if common.DataExportEnabled {
go model.UpdateQuotaData(common.DataExportInterval)
}
// 数据看板
go model.UpdateQuotaData()
if os.Getenv("CHANNEL_UPDATE_FREQUENCY") != "" {
frequency, err := strconv.Atoi(os.Getenv("CHANNEL_UPDATE_FREQUENCY"))
if err != nil {

View File

@ -17,11 +17,13 @@ type QuotaData struct {
Quota int `json:"quota" gorm:"default:0"`
}
func UpdateQuotaData(frequency int) {
func UpdateQuotaData() {
for {
common.SysLog("正在更新数据看板数据...")
SaveQuotaDataCache()
time.Sleep(time.Duration(frequency) * time.Minute)
if common.DataExportEnabled {
common.SysLog("正在更新数据看板数据...")
SaveQuotaDataCache()
}
time.Sleep(time.Duration(common.DataExportInterval) * time.Minute)
}
}