From e760a69a69b9ce9df4891e94252ae249fc8ebd16 Mon Sep 17 00:00:00 2001 From: Christophe Loiseau Date: Fri, 9 Aug 2024 17:27:57 +0200 Subject: [PATCH 1/8] fix: Uptime calculation --- .../web/pages/ComponentStatusApiService.kt | 76 +++++++------------ .../web/services/ComponentStatusService.kt | 24 +++--- .../services/ComponentStatusApiServiceTest.kt | 24 +++++- 3 files changed, 58 insertions(+), 66 deletions(-) diff --git a/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/pages/ComponentStatusApiService.kt b/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/pages/ComponentStatusApiService.kt index 0890e86b1..d8c2a513e 100644 --- a/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/pages/ComponentStatusApiService.kt +++ b/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/pages/ComponentStatusApiService.kt @@ -15,7 +15,7 @@ package de.sovity.authorityportal.web.pages import de.sovity.authorityportal.api.model.ComponentStatusOverview import de.sovity.authorityportal.api.model.UptimeStatusDto -import de.sovity.authorityportal.db.jooq.enums.ComponentOnlineStatus +import de.sovity.authorityportal.db.jooq.enums.ComponentOnlineStatus.UP import de.sovity.authorityportal.db.jooq.enums.ComponentType import de.sovity.authorityportal.db.jooq.enums.ConnectorOnlineStatus import de.sovity.authorityportal.db.jooq.tables.records.ComponentDowntimesRecord @@ -25,11 +25,9 @@ import de.sovity.authorityportal.web.thirdparty.uptimekuma.model.toDto import de.sovity.authorityportal.web.utils.TimeUtils import jakarta.enterprise.context.ApplicationScoped import org.jooq.DSLContext -import java.text.DecimalFormat -import java.text.DecimalFormatSymbols import java.time.Duration +import java.time.Duration.between import java.time.OffsetDateTime -import java.util.Locale @ApplicationScoped class ComponentStatusApiService( @@ -47,7 +45,8 @@ class ComponentStatusApiService( } fun getComponentsStatusForOrganizationId(environmentId: String, organizationId: String): ComponentStatusOverview { - val connectorStatuses = connectorStatusQuery.getConnectorStatusInfoByOrganizationIdAndEnvironment(organizationId, environmentId) + val connectorStatuses = + connectorStatusQuery.getConnectorStatusInfoByOrganizationIdAndEnvironment(organizationId, environmentId) val statusCount = countConnectorStatuses(connectorStatuses) return buildComponenStatusOverview(statusCount, environmentId) @@ -60,7 +59,8 @@ class ComponentStatusApiService( val latestDapsStatus = componentStatusService.getLatestComponentStatus(ComponentType.DAPS, environmentId) val latestLoggingHouseStatus = componentStatusService.getLatestComponentStatus(ComponentType.LOGGING_HOUSE, environmentId) - val latestBrokerCrawlerStatus = componentStatusService.getLatestComponentStatus(ComponentType.CATALOG_CRAWLER, environmentId) + val latestBrokerCrawlerStatus = + componentStatusService.getLatestComponentStatus(ComponentType.CATALOG_CRAWLER, environmentId) val now = timeUtils.now() return ComponentStatusOverview( @@ -82,12 +82,12 @@ class ComponentStatusApiService( return null } - val upSince = Duration.between(latestStatus.timeStamp.toInstant(), now.toInstant()).abs() + val upSince = between(latestStatus.timeStamp.toInstant(), now.toInstant()).abs() val timeSpan = Duration.ofDays(30) return UptimeStatusDto( componentStatus = latestStatus.status.toDto(), - upSinceSeconds = upSince.toSeconds().takeIf { latestStatus.status == ComponentOnlineStatus.UP } ?: 0, + upSinceSeconds = upSince.toSeconds().takeIf { latestStatus.status == UP } ?: 0, timeSpanSeconds = timeSpan.toSeconds(), uptimePercentage = calculateUptimePercentage(latestStatus.component, timeSpan, environmentId, now) ) @@ -100,55 +100,33 @@ class ComponentStatusApiService( now: OffsetDateTime ): Double { val limit = now.minus(timeSpan) - var statusHistoryAsc = componentStatusService.getStatusHistoryAscSince(component, limit, environmentId) - // If no status was found before the limit, the first record in the history is used as base for the calculation - val initialRecord = - componentStatusService.getFirstRecordBefore(component, limit, environmentId) ?: statusHistoryAsc.first() - - // If no "UP" status was found, return 0.00 - // Also, drop all entries before first "UP" status, to avoid wrong uptime calculation - var tmpLastUpStatus = if (initialRecord.status == ComponentOnlineStatus.UP) initialRecord else { - statusHistoryAsc = statusHistoryAsc.dropWhile { it.status != ComponentOnlineStatus.UP } - statusHistoryAsc.firstOrNull() - } - if (tmpLastUpStatus == null) { - return 0.00 - } + val statusHistoryAsc = componentStatusService.getStatusHistoryAscSince(component, limit, environmentId) - // Sum up the total duration of "UP" statuses - var totalUptimeDuration = Duration.ZERO - for (componentRecord in statusHistoryAsc) { - if (componentRecord.status == ComponentOnlineStatus.UP) { - tmpLastUpStatus = componentRecord - } else { - totalUptimeDuration += Duration.between( - tmpLastUpStatus!!.timeStamp.toInstant(), - componentRecord.timeStamp.toInstant() - ).abs() - } - } + if (statusHistoryAsc.isEmpty()) return 0.0 - // Add time if last status is "UP" - val lastRecord = statusHistoryAsc.lastOrNull() ?: tmpLastUpStatus - if (lastRecord!!.status == ComponentOnlineStatus.UP) { - totalUptimeDuration += Duration.between(lastRecord.timeStamp.toInstant(), now.toInstant()).abs() + val first = statusHistoryAsc.first() + + val start = when { + first.timeStamp.isBefore(limit) -> ComponentDowntimesRecord(component, first.status, environmentId, limit) + else -> first } - // Subtract potential uptime before the limit - if (initialRecord.status == ComponentOnlineStatus.UP && initialRecord.timeStamp.isBefore(limit)) { - totalUptimeDuration -= Duration.between(initialRecord.timeStamp.toInstant(), limit.toInstant()).abs() + val middle = statusHistoryAsc.drop(1) + val end = ComponentDowntimesRecord(component, statusHistoryAsc.last().status, environmentId, now) + + val whole = listOf(start) + middle + listOf(end) + + val duration = whole.zipWithNext().fold(Duration.ZERO) { acc, (start, end) -> + when (start.status) { + UP -> acc + between(start.timeStamp, end.timeStamp) + else -> acc + } } - // Calculate uptime percentage - val totalDuration = - Duration.between(initialRecord.timeStamp.toInstant(), now.toInstant()).coerceAtMost(timeSpan).abs() - val uptimePercentage = totalUptimeDuration.toMillis().toDouble() / totalDuration.toMillis().toDouble() * 100 + val uptime = 100.0 * duration.toMillis() / between(start.timeStamp, now).toMillis() - // Round value to two decimal places - val symbols = DecimalFormatSymbols(Locale.US) - val formatter = DecimalFormat("#.##", symbols) - return formatter.format(uptimePercentage).toDouble() + return uptime } private fun countConnectorStatuses( diff --git a/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt b/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt index df7c00615..1e253a6aa 100644 --- a/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt +++ b/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt @@ -55,20 +55,6 @@ class ComponentStatusService( .fetchOne() } - fun getFirstRecordBefore( - component: ComponentType, - limit: OffsetDateTime, - environment: String - ): ComponentDowntimesRecord? { - val c = Tables.COMPONENT_DOWNTIMES - - return dsl.selectFrom(c) - .where(c.COMPONENT.eq(component)).and(c.ENVIRONMENT.eq(environment)).and(c.TIME_STAMP.lessThan(limit)) - .orderBy(c.TIME_STAMP.desc()) - .limit(1) - .fetchOne() - } - fun getStatusHistoryAscSince( component: ComponentType, limit: OffsetDateTime, @@ -77,7 +63,15 @@ class ComponentStatusService( val c = Tables.COMPONENT_DOWNTIMES return dsl.selectFrom(c) - .where(c.COMPONENT.eq(component)).and(c.ENVIRONMENT.eq(environment)).and(c.TIME_STAMP.greaterOrEqual(limit)) + .where(c.COMPONENT.eq(component)).and(c.ENVIRONMENT.eq(environment)) + .and(c.TIME_STAMP.lessThan(limit)) + .orderBy(c.TIME_STAMP.desc()) + .limit(1) + .union( + dsl.selectFrom(c) + .where(c.COMPONENT.eq(component)).and(c.ENVIRONMENT.eq(environment)).and(c.TIME_STAMP.greaterOrEqual(limit)) + .orderBy(c.TIME_STAMP.asc()) + ) .orderBy(c.TIME_STAMP.asc()) .fetch() } diff --git a/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt b/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt index 7351e7749..0bcd8c817 100644 --- a/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt +++ b/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt @@ -52,9 +52,11 @@ class ComponentStatusApiServiceTest { fun getComponentStatusTest() { // arrange val now = OffsetDateTime.now() + // TODO: make this a list val env1 = "test" val env2 = "dev" - setupStatusHistory(now, env1, env2) + val env3 = "env3" + setupStatusHistory(now, env1, env2, env3) useMockNow(now) @@ -96,6 +98,7 @@ class ComponentStatusApiServiceTest { // act val resultEnv1 = componentStatusApiService.getComponentsStatus(env1) val resultEnv2 = componentStatusApiService.getComponentsStatus(env2) + val resultEnv3 = componentStatusApiService.getComponentsStatus(env3) // assert assertThat(resultEnv1.dapsStatus?.componentStatus).isEqualTo(ComponentOnlineStatus.MAINTENANCE.toDto()) @@ -115,9 +118,19 @@ class ComponentStatusApiServiceTest { assertThat(resultEnv2.dapsStatus?.timeSpanSeconds).isEqualTo(Duration.ofDays(30).toSeconds()) assertThat(resultEnv2.dapsStatus?.upSinceSeconds).isEqualTo(Duration.ZERO.toSeconds()) assertThat(resultEnv2.loggingHouseStatus).isNull() + + assertThat(resultEnv3.loggingHouseStatus?.componentStatus).isEqualTo(ComponentOnlineStatus.DOWN.toDto()) + assertThat(resultEnv3.loggingHouseStatus?.uptimePercentage).isCloseTo(50.0, Offset.offset(0.1)) + assertThat(resultEnv3.loggingHouseStatus?.timeSpanSeconds).isEqualTo(Duration.ofDays(30).toSeconds()) + assertThat(resultEnv3.loggingHouseStatus?.upSinceSeconds).isEqualTo(Duration.ZERO.toSeconds()) + + assertThat(resultEnv3.dapsStatus?.componentStatus).isEqualTo(ComponentOnlineStatus.UP.toDto()) + assertThat(resultEnv3.dapsStatus?.uptimePercentage).isCloseTo(100.0, Offset.offset(0.1)) + assertThat(resultEnv3.dapsStatus?.timeSpanSeconds).isEqualTo(Duration.ofDays(30).toSeconds()) + assertThat(resultEnv3.dapsStatus?.upSinceSeconds).isEqualTo(Duration.ofDays(15).toSeconds()) } - private fun setupStatusHistory(now: OffsetDateTime, environment1: String, environment2: String) { + private fun setupStatusHistory(now: OffsetDateTime, environment1: String, environment2: String, environment3: String) { val c = Tables.COMPONENT_DOWNTIMES dsl.insertInto(c) @@ -137,6 +150,13 @@ class ComponentStatusApiServiceTest { // DAPS: Only "DOWN" status, older than 30 days .values(ComponentType.DAPS, ComponentOnlineStatus.DOWN, environment2, now.minus(Duration.ofDays(31))) // LH: Empty + // Environment 3 + // LH: Up + .values(ComponentType.LOGGING_HOUSE, ComponentOnlineStatus.UP, environment3, now.minus(Duration.ofDays(10))) + .values(ComponentType.LOGGING_HOUSE, ComponentOnlineStatus.PENDING, environment3, now.minus(Duration.ofDays(5))) + .values(ComponentType.LOGGING_HOUSE, ComponentOnlineStatus.DOWN, environment3, now.minus(Duration.ofSeconds(1))) + // DAPS: Only "UP" status + .values(ComponentType.DAPS, ComponentOnlineStatus.UP, environment3, now.minus(Duration.ofDays(15))) .execute() } } From 3f7fef54dcfcc0a4339f3e160993f5358ef798b9 Mon Sep 17 00:00:00 2001 From: Christophe Loiseau Date: Fri, 9 Aug 2024 17:32:39 +0200 Subject: [PATCH 2/8] Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index df888dd2a..89f6aecd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ please see [changelog_updates.md](docs/dev/changelog_updates.md). - Already registered connectors will be updated automatically, this process can take up to 24 hours - Added a message when the CaaS request feature is not available - Catalog: Removed dataspace filter when only one dataspace is known +- Uptime: Fix uptime calculation ### Known issues From 66600fa9c07fbf244e0e183ca018755817e98d29 Mon Sep 17 00:00:00 2001 From: Christophe Loiseau Date: Fri, 9 Aug 2024 17:38:33 +0200 Subject: [PATCH 3/8] self review --- .../authorityportal/web/pages/ComponentStatusApiService.kt | 2 -- .../authorityportal/web/services/ComponentStatusService.kt | 6 ++++-- .../web/tests/services/ComponentStatusApiServiceTest.kt | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/pages/ComponentStatusApiService.kt b/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/pages/ComponentStatusApiService.kt index d8c2a513e..f2cdcc549 100644 --- a/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/pages/ComponentStatusApiService.kt +++ b/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/pages/ComponentStatusApiService.kt @@ -103,8 +103,6 @@ class ComponentStatusApiService( val statusHistoryAsc = componentStatusService.getStatusHistoryAscSince(component, limit, environmentId) - if (statusHistoryAsc.isEmpty()) return 0.0 - val first = statusHistoryAsc.first() val start = when { diff --git a/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt b/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt index 1e253a6aa..54f42f40a 100644 --- a/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt +++ b/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt @@ -63,13 +63,15 @@ class ComponentStatusService( val c = Tables.COMPONENT_DOWNTIMES return dsl.selectFrom(c) - .where(c.COMPONENT.eq(component)).and(c.ENVIRONMENT.eq(environment)) + .where(c.COMPONENT.eq(component)) + .and(c.ENVIRONMENT.eq(environment)) .and(c.TIME_STAMP.lessThan(limit)) .orderBy(c.TIME_STAMP.desc()) .limit(1) .union( dsl.selectFrom(c) - .where(c.COMPONENT.eq(component)).and(c.ENVIRONMENT.eq(environment)).and(c.TIME_STAMP.greaterOrEqual(limit)) + .where(c.COMPONENT.eq(component)).and(c.ENVIRONMENT.eq(environment)) + .and(c.TIME_STAMP.greaterOrEqual(limit)) .orderBy(c.TIME_STAMP.asc()) ) .orderBy(c.TIME_STAMP.asc()) diff --git a/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt b/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt index 0bcd8c817..edd674f13 100644 --- a/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt +++ b/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt @@ -52,7 +52,6 @@ class ComponentStatusApiServiceTest { fun getComponentStatusTest() { // arrange val now = OffsetDateTime.now() - // TODO: make this a list val env1 = "test" val env2 = "dev" val env3 = "env3" From 41ac1373f1102bb66a0e3512775fd3a8c1dac647 Mon Sep 17 00:00:00 2001 From: Christophe Loiseau Date: Fri, 9 Aug 2024 17:45:29 +0200 Subject: [PATCH 4/8] Fix test --- .../web/tests/services/ComponentStatusApiServiceTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt b/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt index edd674f13..6bbcef1f5 100644 --- a/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt +++ b/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt @@ -126,7 +126,7 @@ class ComponentStatusApiServiceTest { assertThat(resultEnv3.dapsStatus?.componentStatus).isEqualTo(ComponentOnlineStatus.UP.toDto()) assertThat(resultEnv3.dapsStatus?.uptimePercentage).isCloseTo(100.0, Offset.offset(0.1)) assertThat(resultEnv3.dapsStatus?.timeSpanSeconds).isEqualTo(Duration.ofDays(30).toSeconds()) - assertThat(resultEnv3.dapsStatus?.upSinceSeconds).isEqualTo(Duration.ofDays(15).toSeconds()) + assertThat(resultEnv3.dapsStatus?.upSinceSeconds).isCloseTo(Duration.ofDays(15).toSeconds(), Offset.offset(10L)) } private fun setupStatusHistory(now: OffsetDateTime, environment1: String, environment2: String, environment3: String) { From aa5b2ac2f6568d0aa1eda9d4c8af10da56ae831d Mon Sep 17 00:00:00 2001 From: Christophe Loiseau Date: Fri, 9 Aug 2024 17:47:43 +0200 Subject: [PATCH 5/8] Fix test --- .../web/tests/services/ComponentStatusApiServiceTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt b/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt index 6bbcef1f5..9e8af2f48 100644 --- a/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt +++ b/authority-portal-backend/authority-portal-quarkus/src/test/kotlin/de/sovity/authorityportal/web/tests/services/ComponentStatusApiServiceTest.kt @@ -126,7 +126,7 @@ class ComponentStatusApiServiceTest { assertThat(resultEnv3.dapsStatus?.componentStatus).isEqualTo(ComponentOnlineStatus.UP.toDto()) assertThat(resultEnv3.dapsStatus?.uptimePercentage).isCloseTo(100.0, Offset.offset(0.1)) assertThat(resultEnv3.dapsStatus?.timeSpanSeconds).isEqualTo(Duration.ofDays(30).toSeconds()) - assertThat(resultEnv3.dapsStatus?.upSinceSeconds).isCloseTo(Duration.ofDays(15).toSeconds(), Offset.offset(10L)) + assertThat(resultEnv3.dapsStatus?.upSinceSeconds).isCloseTo(Duration.ofDays(15).toSeconds(), Offset.offset(1L)) } private fun setupStatusHistory(now: OffsetDateTime, environment1: String, environment2: String, environment3: String) { From 0262448315cf97059c8335b9d1e4fa47125cbe50 Mon Sep 17 00:00:00 2001 From: Christophe Loiseau Date: Fri, 9 Aug 2024 17:56:36 +0200 Subject: [PATCH 6/8] Code review --- .../web/pages/ComponentStatusApiService.kt | 10 +++++----- .../web/services/ComponentStatusService.kt | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/pages/ComponentStatusApiService.kt b/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/pages/ComponentStatusApiService.kt index f2cdcc549..dd7555262 100644 --- a/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/pages/ComponentStatusApiService.kt +++ b/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/pages/ComponentStatusApiService.kt @@ -105,15 +105,15 @@ class ComponentStatusApiService( val first = statusHistoryAsc.first() - val start = when { + val head = when { first.timeStamp.isBefore(limit) -> ComponentDowntimesRecord(component, first.status, environmentId, limit) else -> first } - val middle = statusHistoryAsc.drop(1) - val end = ComponentDowntimesRecord(component, statusHistoryAsc.last().status, environmentId, now) + val body = statusHistoryAsc.drop(1) + val tail = ComponentDowntimesRecord(component, statusHistoryAsc.last().status, environmentId, now) - val whole = listOf(start) + middle + listOf(end) + val whole = listOf(head) + body + listOf(tail) val duration = whole.zipWithNext().fold(Duration.ZERO) { acc, (start, end) -> when (start.status) { @@ -122,7 +122,7 @@ class ComponentStatusApiService( } } - val uptime = 100.0 * duration.toMillis() / between(start.timeStamp, now).toMillis() + val uptime = 100.0 * duration.toMillis() / between(head.timeStamp, now).toMillis() return uptime } diff --git a/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt b/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt index 54f42f40a..0cceace51 100644 --- a/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt +++ b/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt @@ -72,7 +72,6 @@ class ComponentStatusService( dsl.selectFrom(c) .where(c.COMPONENT.eq(component)).and(c.ENVIRONMENT.eq(environment)) .and(c.TIME_STAMP.greaterOrEqual(limit)) - .orderBy(c.TIME_STAMP.asc()) ) .orderBy(c.TIME_STAMP.asc()) .fetch() From f939fbc2bf0797aaadd9670afddf7cc2b8a030eb Mon Sep 17 00:00:00 2001 From: Kamil Czaja Date: Mon, 12 Aug 2024 15:58:37 +0200 Subject: [PATCH 7/8] chore: refactor --- .../web/services/ComponentStatusService.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt b/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt index 0cceace51..56059ddc2 100644 --- a/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt +++ b/authority-portal-backend/authority-portal-quarkus/src/main/kotlin/de/sovity/authorityportal/web/services/ComponentStatusService.kt @@ -49,7 +49,7 @@ class ComponentStatusService( val c = Tables.COMPONENT_DOWNTIMES return dsl.selectFrom(c) - .where(c.COMPONENT.eq(component)).and(c.ENVIRONMENT.eq(environment)) + .where(c.COMPONENT.eq(component), c.ENVIRONMENT.eq(environment)) .orderBy(c.TIME_STAMP.desc()) .limit(1) .fetchOne() @@ -63,15 +63,20 @@ class ComponentStatusService( val c = Tables.COMPONENT_DOWNTIMES return dsl.selectFrom(c) - .where(c.COMPONENT.eq(component)) - .and(c.ENVIRONMENT.eq(environment)) - .and(c.TIME_STAMP.lessThan(limit)) + .where( + c.COMPONENT.eq(component), + c.ENVIRONMENT.eq(environment), + c.TIME_STAMP.lessThan(limit) + ) .orderBy(c.TIME_STAMP.desc()) .limit(1) .union( dsl.selectFrom(c) - .where(c.COMPONENT.eq(component)).and(c.ENVIRONMENT.eq(environment)) - .and(c.TIME_STAMP.greaterOrEqual(limit)) + .where( + c.COMPONENT.eq(component), + c.ENVIRONMENT.eq(environment), + c.TIME_STAMP.greaterOrEqual(limit) + ) ) .orderBy(c.TIME_STAMP.asc()) .fetch() From c82154dd576b4eaf2f6e13ff33125c09b94a1b6f Mon Sep 17 00:00:00 2001 From: Richard Treier Date: Mon, 12 Aug 2024 16:03:01 +0200 Subject: [PATCH 8/8] chore: CHANGELOG nits --- CHANGELOG.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86993346a..f31153b71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,19 +13,20 @@ please see [changelog_updates.md](docs/dev/changelog_updates.md). #### Minor +- Copyable contact email and subject fields on data offer detail dialogs +- Catalog: Organization filter is no longer split into ID and name +- Catalog: Connector filter is no longer split into ID and endpoint +- Catalog: Removed dataspace filter when only one dataspace is known +- Added a message when the CaaS request feature is not available + #### Patch -- Copyable contact email and subject fields on data offer detail dialogs -- Fixed the close button on the self-hosted/CaaS connector choice page [#258](https://github.com/sovity/authority-portal/issues/258) +- Fixed Dashboard showing uptimes of over 100% +- Organization list: Data offer and connector counts now show the correct numbers according to the active environment - Fixed provider organization ID not showing up on CaaS connectors [#206](https://github.com/sovity/authority-portal/issues/206) - Keep in mind that sovity needs to be registered in the portal for the ID to show up. - Already registered connectors will be updated automatically, this process can take up to 24 hours -- Added a message when the CaaS request feature is not available -- Catalog: Removed dataspace filter when only one dataspace is known -- Uptime: Fix uptime calculation -- Catalog: Organization filter is no longer split into ID and name -- Catalog: Connector filter is no longer split into ID and endpoint -- Organization list: Data offer and connector counts now show the correct numbers according to the active environment +- Fixed the close button on the self-hosted/CaaS connector choice page [#258](https://github.com/sovity/authority-portal/issues/258) ### Known issues