From e99b08bcc380562d8b266ef1067caa6fe94aeeb5 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Wed, 15 Feb 2023 11:03:13 +0400 Subject: [PATCH] fix: Improve DigitalOcean server types filtering - Convert RAM to GB - Don't let it droplets with RAM less than 1024 MB --- .../server_providers/digital_ocean/digital_ocean.dart | 5 +++-- lib/logic/models/server_type.dart | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/logic/api_maps/rest_maps/server_providers/digital_ocean/digital_ocean.dart b/lib/logic/api_maps/rest_maps/server_providers/digital_ocean/digital_ocean.dart index 4beb53f7..b2f4c624 100644 --- a/lib/logic/api_maps/rest_maps/server_providers/digital_ocean/digital_ocean.dart +++ b/lib/logic/api_maps/rest_maps/server_providers/digital_ocean/digital_ocean.dart @@ -808,12 +808,13 @@ class DigitalOceanApi extends ServerProviderApi with VolumeProviderApi { final rawSizes = response.data!['sizes']; for (final rawSize in rawSizes) { for (final rawRegion in rawSize['regions']) { - if (rawRegion.toString() == location.identifier) { + final ramMb = rawSize['memory'].toDouble(); + if (rawRegion.toString() == location.identifier && ramMb > 1024) { types.add( ServerType( title: rawSize['description'], identifier: rawSize['slug'], - ram: rawSize['memory'].toDouble(), + ram: ramMb / 1024, cores: rawSize['vcpus'], disk: DiskSize(byte: rawSize['disk'] * 1024 * 1024 * 1024), price: Price( diff --git a/lib/logic/models/server_type.dart b/lib/logic/models/server_type.dart index 4e7b8d92..3bdb9baa 100644 --- a/lib/logic/models/server_type.dart +++ b/lib/logic/models/server_type.dart @@ -14,7 +14,7 @@ class ServerType { }); final String title; final String identifier; - final double ram; + final double ram; // GB !! final DiskSize disk; final int cores; final Price price;