From 27ed533530d65424e5f3d0b222af2c4ae220b9ef Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Mon, 22 Apr 2024 15:12:12 +0800 Subject: [PATCH 1/2] Refactor(Statistics): Correct incorrect spelling Correct WEAK to WEEK --- .../oxygen/api/param/system/ActiveInfoGetParam.kt | 10 +++++----- .../oxygen/api/param/system/OnlineInfoGetParam.kt | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/system/ActiveInfoGetParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/system/ActiveInfoGetParam.kt index c085c80..de4c1ba 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/system/ActiveInfoGetParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/system/ActiveInfoGetParam.kt @@ -20,14 +20,14 @@ data class ActiveInfoGetParam( */ @Schema( description = "范围", - allowableValues = ["WEAK", "MONTH", "QUARTER", "YEAR", "TWO_YEARS", "THREE_YEARS", "FIVE_YEARS", "ALL"], - defaultValue = "WEAK", - example = "WEAK" + allowableValues = ["WEEK", "MONTH", "QUARTER", "YEAR", "TWO_YEARS", "THREE_YEARS", "FIVE_YEARS", "ALL"], + defaultValue = "WEEK", + example = "WEEK" ) - val scope: Scope = Scope.WEAK + val scope: Scope = Scope.WEEK ) { enum class Scope(@field:EnumValue @field:JsonValue val code: String) { - WEAK("WEAK"), + WEEK("WEEK"), MONTH("MONTH"), diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/system/OnlineInfoGetParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/system/OnlineInfoGetParam.kt index 932f10e..d00d9eb 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/system/OnlineInfoGetParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/system/OnlineInfoGetParam.kt @@ -20,16 +20,16 @@ data class OnlineInfoGetParam( */ @Schema( description = "范围", - allowableValues = ["WEAK", "MONTH", "QUARTER", "YEAR", "TWO_YEARS", "THREE_YEARS", "FIVE_YEARS", "ALL"], - defaultValue = "WEAK", - example = "WEAK" + allowableValues = ["WEEK", "MONTH", "QUARTER", "YEAR", "TWO_YEARS", "THREE_YEARS", "FIVE_YEARS", "ALL"], + defaultValue = "WEEK", + example = "WEEK" ) - val scope: Scope = Scope.WEAK + val scope: Scope = Scope.WEEK ) { enum class Scope(@field:EnumValue @field:JsonValue val code: String) { DAY("DAY"), - WEAK("WEAK"), + WEEK("WEEK"), MONTH("MONTH"), -- 2.49.1 From eb031fefb3ed97aeecc6cecc9a2e9e4e3fd81741 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Mon, 22 Apr 2024 15:13:45 +0800 Subject: [PATCH 2/2] Refactor(Statistics): Optimize memory and hard disk capacity display Unknown is displayed when detailed capacity cannot be obtained --- .../api/service/system/impl/StatisticsServiceImpl.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/system/impl/StatisticsServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/system/impl/StatisticsServiceImpl.kt index e6394f8..ae264a7 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/system/impl/StatisticsServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/system/impl/StatisticsServiceImpl.kt @@ -66,15 +66,17 @@ class StatisticsServiceImpl( cpuLogicalProcessorCount = systemInfo.hardware.processor.logicalProcessorCount, microarchitecture = systemInfo.hardware.processor.processorIdentifier.microarchitecture, memories = "${ByteUtil.formatByteSize(systemInfo.hardware.memory.total)} (${ - systemInfo.hardware.memory.physicalMemory.joinToString( + if (systemInfo.hardware.memory.physicalMemory.size > 0) systemInfo.hardware.memory.physicalMemory.joinToString( " + " ) { ByteUtil.formatByteSize(it.capacity) } + else "Unknown" })", - disks = "${ByteUtil.formatByteSize(systemInfo.hardware.diskStores.sumOf { it.size })} (${ + disks = if (systemInfo.hardware.diskStores.size > 0) "${ByteUtil.formatByteSize(systemInfo.hardware.diskStores.sumOf { it.size })} (${ systemInfo.hardware.diskStores.joinToString( " + " ) { ByteUtil.formatByteSize(it.size) } })" + else "Unknown" ) override fun cpu(): CpuInfoVo { @@ -190,7 +192,11 @@ class StatisticsServiceImpl( return OnlineInfoVo( current = redisUtil.keys("${SecurityProperties.jwtIssuer}_login_*") - .distinctBy { Regex("${SecurityProperties.jwtIssuer}_login_(.*):.*").matchEntire(it)?.groupValues?.getOrNull(1) }.size.toLong(), + .distinctBy { + Regex("${SecurityProperties.jwtIssuer}_login_(.*):.*").matchEntire(it)?.groupValues?.getOrNull( + 1 + ) + }.size.toLong(), history = history ) } -- 2.49.1