Rename statistic to statistics

This commit is contained in:
2023-12-20 11:32:47 +08:00
parent b2b4ac5302
commit 60353906ad
14 changed files with 83 additions and 66 deletions

View File

@@ -0,0 +1,23 @@
package top.fatweb.api.cron
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Component
import top.fatweb.api.entity.system.StatisticsLog
import top.fatweb.api.properties.SecurityProperties
import top.fatweb.api.service.system.IStatisticsLogService
import top.fatweb.api.util.RedisUtil
@Component
class StatisticsCron(
private val redisUtil: RedisUtil,
private val statisticsLogService: IStatisticsLogService
) {
@Scheduled(cron = "0 * * * * *")
fun onlineUserCount() {
statisticsLogService.save(StatisticsLog().apply {
key = StatisticsLog.KeyItem.ONLINE_USERS_COUNT
value = redisUtil.keys("${SecurityProperties.jwtIssuer}_login_*")
.distinctBy { Regex("FatWeb_login_(.*):.*").matchEntire(it)?.groupValues?.getOrNull(1) }.size.toString()
})
}
}