From a48c19833b4a00463f691dfbe776f073b56bcd79 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Thu, 1 Aug 2024 14:25:59 +0200 Subject: [PATCH] fix rentedinstance object --- .../eu/m724/vastapp/vastai/data/RentedInstance.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/m724/vastapp/vastai/data/RentedInstance.kt b/app/src/main/java/eu/m724/vastapp/vastai/data/RentedInstance.kt index c822d67..8a41c81 100644 --- a/app/src/main/java/eu/m724/vastapp/vastai/data/RentedInstance.kt +++ b/app/src/main/java/eu/m724/vastapp/vastai/data/RentedInstance.kt @@ -50,17 +50,17 @@ data class RentedInstance( Instance.fromJson(json), json.getDouble("disk_space"), json.getDouble("disk_util"), - (StorageCapacityConverters.gibToGb(json.getDouble("vmem_usage")) / 1000).toInt(), - (json.getDouble("mem_usage") / 1000).toInt(), - json.getDouble("gpu_util") / 100, + (StorageCapacityConverters.gibToGb(json.optDouble("vmem_usage")) / 1000).toInt(), + (json.optDouble("mem_usage") / 1000).toInt(), + json.optDouble("gpu_util") / 100, json.getDouble("cpu_util") / 100, - json.getDouble("gpu_temp"), - json.getDouble("inet_down_billed").toInt(), - json.getDouble("inet_up_billed").toInt(), + json.optDouble("gpu_temp"), + json.optDouble("inet_down_billed").toInt(), + json.optDouble("inet_up_billed").toInt(), json.getString("ssh_host"), json.getInt("ssh_port"), json.getString("image_uuid"), - json.optString("label").takeIf { it.isNotBlank() }, + json.optString("label").takeUnless { it == "null" || it.isBlank() }, json.getString("local_ipaddrs").split(" ").filterNot { it == "\n" } ) }