fix instance objects

This commit is contained in:
Minecon724 2024-07-31 15:52:46 +02:00
parent a0ba813d5f
commit c10484f698
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
2 changed files with 3 additions and 3 deletions

View file

@ -24,7 +24,7 @@ data class Instance(
* at least I think because it's recent and unavailable machines don't have that */ * at least I think because it's recent and unavailable machines don't have that */
val startDate: Long, val startDate: Long,
/** when instance will expire as unix seconds, like 1861891577 */ /** when instance will expire as unix seconds, like 1861891577 */
val endDate: Long val endDate: Long?
) { ) {
companion object { companion object {
fun fromJson(json: JSONObject): Instance { fun fromJson(json: JSONObject): Instance {
@ -36,7 +36,7 @@ data class Instance(
json.getInt("num_gpus"), json.getInt("num_gpus"),
json.getDouble("dlperf"), json.getDouble("dlperf"),
json.getDouble("start_date").toLong(), json.getDouble("start_date").toLong(),
json.getDouble("end_date").toLong() json.optLong("end_date").takeIf { it > 0 }
) )
} }
} }

View file

@ -65,7 +65,7 @@ data class Machine(
json.getString("mobo_name"), json.getString("mobo_name"),
json.getInt("cpu_ram"), json.getInt("cpu_ram"),
json.getDouble("reliability2"), json.getDouble("reliability2"),
HostingClass.entries.getOrElse(json.getInt("hostingType")) { HostingClass.PRIVATE }, HostingClass.entries.getOrElse(json.optInt("hosting_type", 0)) { HostingClass.PRIVATE },
MachineVerification.fromString(json.getString("verification")) MachineVerification.fromString(json.getString("verification"))
) )
} }