From 3850a0b86a0efd38e4c3ae7531ab0c1816b6812b Mon Sep 17 00:00:00 2001 From: Santeri Korri Date: Tue, 3 Dec 2024 10:53:54 +0200 Subject: [PATCH] =?UTF-8?q?OK-611=20Lis=C3=A4tty=20jononpituus=20endpoint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../valintalaskenta/actor/LaskentaResurssiProvider.java | 7 +++++++ .../resource/ValintalaskentaKerrallaResource.java | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/fi/vm/sade/valinta/kooste/valintalaskenta/actor/LaskentaResurssiProvider.java b/src/main/java/fi/vm/sade/valinta/kooste/valintalaskenta/actor/LaskentaResurssiProvider.java index 885ff8d09..d5cae577c 100644 --- a/src/main/java/fi/vm/sade/valinta/kooste/valintalaskenta/actor/LaskentaResurssiProvider.java +++ b/src/main/java/fi/vm/sade/valinta/kooste/valintalaskenta/actor/LaskentaResurssiProvider.java @@ -140,6 +140,13 @@ public void lueParametrit() { }); } + public int jononpituus() { + return this.limiters.values().stream() + .map(l -> l.getWaiting()) + .max(Integer::compareTo) + .orElseThrow(); + } + private void tallennaLokitJaMetriikat( String hakukohdeOid, Map waitDurations, diff --git a/src/main/java/fi/vm/sade/valinta/kooste/valintalaskenta/resource/ValintalaskentaKerrallaResource.java b/src/main/java/fi/vm/sade/valinta/kooste/valintalaskenta/resource/ValintalaskentaKerrallaResource.java index d82bd8774..aaaadf768 100644 --- a/src/main/java/fi/vm/sade/valinta/kooste/valintalaskenta/resource/ValintalaskentaKerrallaResource.java +++ b/src/main/java/fi/vm/sade/valinta/kooste/valintalaskenta/resource/ValintalaskentaKerrallaResource.java @@ -55,6 +55,11 @@ private static Throwable getUnderlyingCause(Throwable t) { return t; } + @GetMapping(value = "/lahtotiedot/jononpituus", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity jononpituus() { + return ResponseEntity.status(HttpStatus.OK).body(this.laskentaResurssiProvider.jononpituus()); + } + @GetMapping( value = "/haku/{hakuOid}/hakukohde/{hakukohdeOid}/lahtotiedot", produces = MediaType.APPLICATION_JSON_VALUE)