From f0e5f64b86148cbae3e7524a94f7eeb5605149fb Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Fri, 31 May 2024 18:12:24 +0200 Subject: [PATCH] Restore legacy load Signed-off-by: Paolo Di Tommaso --- .../impl/SurrealPersistenceService.groovy | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/groovy/io/seqera/wave/service/persistence/impl/SurrealPersistenceService.groovy b/src/main/groovy/io/seqera/wave/service/persistence/impl/SurrealPersistenceService.groovy index 1d2551774..f47ded54c 100644 --- a/src/main/groovy/io/seqera/wave/service/persistence/impl/SurrealPersistenceService.groovy +++ b/src/main/groovy/io/seqera/wave/service/persistence/impl/SurrealPersistenceService.groovy @@ -29,6 +29,7 @@ import io.micronaut.http.client.exceptions.HttpClientResponseException import io.micronaut.runtime.event.ApplicationStartupEvent import io.micronaut.runtime.event.annotation.EventListener import io.seqera.wave.core.ContainerDigestPair +import io.seqera.wave.service.builder.BuildRequest import io.seqera.wave.service.persistence.PersistenceService import io.seqera.wave.service.persistence.WaveBuildRecord import io.seqera.wave.service.persistence.WaveContainerRecord @@ -109,6 +110,24 @@ class SurrealPersistenceService implements PersistenceService { WaveBuildRecord loadBuild(String buildId) { if( !buildId ) throw new IllegalArgumentException("Missing 'buildId' argument") + def result = loadBuild0(buildId) + if( result ) + return result + // try to lookup legacy record + final legacyId = BuildRequest.legacyBuildId(buildId) + return legacyId ? loadBuild1(legacyId) : null + } + + private WaveBuildRecord loadBuild0(String buildId) { + final query = "select * from wave_build where buildId = '$buildId'" + final json = surrealDb.sqlAsString(getAuthorization(), query) + final type = new TypeReference>>() {} + final data= json ? JacksonHelper.fromJson(json, type) : null + final result = data && data[0].result ? data[0].result[0] : null + return result + } + + private WaveBuildRecord loadBuild1(String buildId) { final query = "select * from wave_build where buildId = '$buildId'" final json = surrealDb.sqlAsString(getAuthorization(), query) final type = new TypeReference>>() {}