mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-05-25 22:54:43 +00:00
agent: reset stats startedAt time in memory
This commit is contained in:
@@ -2001,10 +2001,12 @@ setNtfServers c = atomically . writeTVar (ntfServers c)
|
||||
{-# INLINE setNtfServers #-}
|
||||
|
||||
resetAgentServersStats' :: AgentClient -> AM ()
|
||||
resetAgentServersStats' c@AgentClient {smpServersStats, xftpServersStats} = do
|
||||
resetAgentServersStats' c@AgentClient {smpServersStats, xftpServersStats, srvStatsStartedAt} = do
|
||||
startedAt <- liftIO getCurrentTime
|
||||
atomically $ writeTVar srvStatsStartedAt startedAt
|
||||
atomically $ TM.clear smpServersStats
|
||||
atomically $ TM.clear xftpServersStats
|
||||
withStore' c resetServersStats
|
||||
withStore' c (`resetServersStats` startedAt)
|
||||
|
||||
-- | Activate operations
|
||||
foregroundAgent :: AgentClient -> IO ()
|
||||
|
||||
@@ -3032,10 +3032,9 @@ getServersStats db =
|
||||
firstRow id SEServersStatsNotFound $
|
||||
DB.query_ db "SELECT started_at, servers_stats FROM servers_stats WHERE servers_stats_id = 1"
|
||||
|
||||
resetServersStats :: DB.Connection -> IO ()
|
||||
resetServersStats db = do
|
||||
currentTs <- getCurrentTime
|
||||
DB.execute db "UPDATE servers_stats SET servers_stats = NULL, started_at = ?, updated_at = ? WHERE servers_stats_id = 1" (currentTs, currentTs)
|
||||
resetServersStats :: DB.Connection -> UTCTime -> IO ()
|
||||
resetServersStats db startedAt =
|
||||
DB.execute db "UPDATE servers_stats SET servers_stats = NULL, started_at = ?, updated_at = ? WHERE servers_stats_id = 1" (startedAt, startedAt)
|
||||
|
||||
$(J.deriveJSON defaultJSON ''UpMigration)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user