From d58ae43e786e2d8cd0140fe23f32177331bc09d3 Mon Sep 17 00:00:00 2001 From: Z-100 Date: Thu, 25 Jan 2024 08:20:50 +0100 Subject: [PATCH] le fix Le fix :) --- soemi-woeb/src/App.js | 4 ++-- .../src/main/kotlin/ch/soemiweather/Application.kt | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/soemi-woeb/src/App.js b/soemi-woeb/src/App.js index d6706e8..824e7de 100644 --- a/soemi-woeb/src/App.js +++ b/soemi-woeb/src/App.js @@ -27,12 +27,12 @@ function App() { } export function Planet({ planet }) { - const {name, img} = planet + const {name, image} = planet return ( <>

Name: {name}

- Star Wars Planet + Star Wars Planet ); } diff --git a/soemi-woers/src/main/kotlin/ch/soemiweather/Application.kt b/soemi-woers/src/main/kotlin/ch/soemiweather/Application.kt index db1f75a..23451da 100644 --- a/soemi-woers/src/main/kotlin/ch/soemiweather/Application.kt +++ b/soemi-woers/src/main/kotlin/ch/soemiweather/Application.kt @@ -15,6 +15,9 @@ import java.io.FileNotFoundException import java.io.InputStreamReader import java.nio.charset.StandardCharsets.UTF_8 +const val MAX_TEMP = 55 +const val MIN_TEMP = -90 + fun main() { embeddedServer(Netty, port = 8089) { install(CORS) { @@ -58,7 +61,10 @@ fun getPlanetForTemp(temp: Double): Planet { .map { it.split(";") } .map { Planet(Integer.parseInt(it[0]), it[1], it[2]) } - return planets.first { it.temp == (5 * Math.round(temp / 5)).toInt() } + val planet = planets.firstOrNull { it.temp == 5 * Math.round(temp / 5).toInt() } + ?: planets.first { if (temp > 0) it.temp == MAX_TEMP else it.temp == MIN_TEMP } + + return planet } fun getFileContent(uri: String): List {