mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-18 08:26:37 +08:00
fix: 优化数据看板更新逻辑
This commit is contained in:
parent
bf8794d257
commit
ce05e7dd86
7
main.go
7
main.go
@ -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 {
|
||||
|
@ -17,11 +17,13 @@ type QuotaData struct {
|
||||
Quota int `json:"quota" gorm:"default:0"`
|
||||
}
|
||||
|
||||
func UpdateQuotaData(frequency int) {
|
||||
func UpdateQuotaData() {
|
||||
for {
|
||||
if common.DataExportEnabled {
|
||||
common.SysLog("正在更新数据看板数据...")
|
||||
SaveQuotaDataCache()
|
||||
time.Sleep(time.Duration(frequency) * time.Minute)
|
||||
}
|
||||
time.Sleep(time.Duration(common.DataExportInterval) * time.Minute)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user