@@ -3,7 +3,7 @@ import Foundation
33/// 入力統計情報を管理するシングルトンクラス
44class InputStats {
55 static let i = InputStats ( )
6-
6+
77 private var lastSyncDate = Date ( )
88
99 private var basicCount = 0
@@ -210,7 +210,7 @@ class InputStats {
210210 }
211211 }
212212 /// 統計情報をファイルに書き出す
213- public func writeStatsToFile( ) {
213+ public func writeStatsToFile( force : Bool = false ) {
214214 queue. sync {
215215 // 学習データも同じタイミングで保存
216216 MazegakiDict . i. saveMruData ( )
@@ -220,10 +220,13 @@ class InputStats {
220220 lastSyncDate = Date ( )
221221 return
222222 }
223- guard UserConfigs . i. system. syncStatsInterval > 0 else {
224- return
223+ // If not forced, obey syncStatsInterval; if forced (manual/menu/signal), allow write even when interval == 0
224+ if !force {
225+ guard UserConfigs . i. system. syncStatsInterval > 0 else {
226+ return
227+ }
225228 }
226-
229+
227230 let fileManager = FileManager . default
228231 let fileURL = UserConfigs . i. configFileURL ( " tc-record.txt " )
229232
@@ -241,11 +244,11 @@ class InputStats {
241244
242245 // 統計行を作成
243246 let statsLine = String ( format: " %@ 文字: %4d 部首: %3d(%d%%) 交ぜ書き: %3d(%d%%) 機能: %3d(%d%%) \n " ,
244- dateString,
245- basicCount,
246- bushuCount, bushuPercent,
247- mazegakiCount, mazegakiPercent,
248- functionCount, functionPercent)
247+ dateString,
248+ basicCount,
249+ bushuCount, bushuPercent,
250+ mazegakiCount, mazegakiPercent,
251+ functionCount, functionPercent)
249252
250253 // ファイルに追記
251254 if let data = statsLine. data ( using: . utf8) {
0 commit comments