export const DESCRIPTION = {
cores: "price per month for 1 vCPU",
memory: "price per month for 1GB of RAM",
disk_quota: "price per month for 1GB of disk",
member_host: "non-disk part of non-member hosting cost is divided by this",
};
export function getPricePerHour(
quota: {
cores?: number;
disk_quota?: number;
memory?: number;
member_host?: number;
},
price_per_month: {
cores: number;
disk_quota: number;
memory: number;
member_host: number;
}
): number {
let price =
(quota.cores ?? 1) * price_per_month.cores +
((quota.memory ?? 1000) * price_per_month.memory) / 1000;
if (!quota.member_host) {
price /= price_per_month.member_host;
}
if (quota.disk_quota && quota.disk_quota > 3000) {
price += ((quota.disk_quota - 3000) * price_per_month.disk_quota) / 1000;
}
price /= 24 * 30.5;
return price;
}