Path: blob/master/src/packages/util/purchases/project-quotas.ts
6028 views
export const DESCRIPTION = {1cores: "price per month for 1 vCPU",2memory: "price per month for 1GB of RAM",3disk_quota: "price per month for 1GB of disk",4member_host: "non-disk part of non-member hosting cost is divided by this",5};67export function getPricePerHour(8quota: {9cores?: number;10disk_quota?: number;11memory?: number;12member_host?: number;13},14price_per_month: {15cores: number; // price per month for 1 vCPU16disk_quota: number; // price per month for 1GB of disk17memory: number; // price per month for 1GB RAM18member_host: number; // cost multiple for non pre-emptible/less loaded (i.e., member hosting)19}20): number {21// start with the core and memory pricing, which are separate.22let price =23(quota.cores ?? 1) * price_per_month.cores +24((quota.memory ?? 1000) * price_per_month.memory) / 1000;2526// member hosting27if (!quota.member_host) {28price /= price_per_month.member_host;29}3031// disk price doesn't depend on member or not.32// The first 3GB are included for free.33if (quota.disk_quota && quota.disk_quota > 3000) {34price += ((quota.disk_quota - 3000) * price_per_month.disk_quota) / 1000;35}3637// convert from month to hour38price /= 24 * 30.5;3940return price;41}424344