Skip to content

Commit

Permalink
shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
timkoopmans committed Feb 4, 2025
1 parent f1615c4 commit e747740
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions src/calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export function calculateScyllaCosts() {
};
}

function getPricing() {
cfg.pricing = document.querySelector('input[name="pricing"]:checked').value;
}

function getTableClass() {
cfg.tableClass = document.getElementById('tableClass').value;
}
Expand Down Expand Up @@ -166,40 +170,6 @@ function calculateDaxCosts() {
cfg.dynamoDaxCost = cfg.daxNodes * cfg.hoursPerMonth * cfg.daxInstanceClassCost;
}

export function updateCosts() {
getSelectedPricingModel();
getTableClass();
getReplicatedRegions()
getStorageValues();
getConsistencyValues();
getRatioValues();
getDemandValues();
getProvisionedValues();
getDaxValues();

calculateProvisionedCosts();
calculateDemandCosts();
calculateStorageCost();
calculateTotalOpsSec();
calculateNetworkCosts();
calculateDaxCosts();

cfg.dynamoCostTotal = cfg.pricing === 'demand' ?
cfg.dynamoCostDemand + cfg.dynamoCostStorage :
cfg.dynamoCostProvisioned + cfg.dynamoCostStorage;

cfg.dynamoCostTotal = cfg.dynamoCostTotal + cfg.dynamoCostNetwork + cfg.dynamoCostReplication + cfg.dynamoDaxCost;

const scyllaResult = calculateScyllaCosts();

const savings = cfg.dynamoCostTotal / 2;
const costRatio = (cfg.dynamoCostTotal / scyllaResult.scyllaCost).toFixed(1);

document.getElementById('costDiff').textContent = `$${formatNumber(savings)}`;

logCosts(scyllaResult, costRatio);
}

export function calculateStorageCost() {
cfg.dynamoCostStorage = cfg.storageGB * 0.25;
}
Expand All @@ -210,10 +180,6 @@ function calculateTotalOpsSec() {
cfg.totalOpsSec = cfg.readsOpsSec + cfg.writesOpsSec;
}

function getSelectedPricingModel() {
cfg.pricing = document.querySelector('input[name="pricing"]:checked').value;
}

function logCosts(scyllaResult, costRatio) {
let logs = [
`itemSizeKB: ${cfg.itemSizeKB} KB`,
Expand Down Expand Up @@ -287,3 +253,37 @@ export function updateOps() {
};
}
}

export function updateCosts() {
getPricing();
getTableClass();
getReplicatedRegions()
getStorageValues();
getConsistencyValues();
getRatioValues();
getDemandValues();
getProvisionedValues();
getDaxValues();

calculateProvisionedCosts();
calculateDemandCosts();
calculateStorageCost();
calculateTotalOpsSec();
calculateNetworkCosts();
calculateDaxCosts();

cfg.dynamoCostTotal = cfg.pricing === 'demand' ?
cfg.dynamoCostDemand + cfg.dynamoCostStorage :
cfg.dynamoCostProvisioned + cfg.dynamoCostStorage;

cfg.dynamoCostTotal = cfg.dynamoCostTotal + cfg.dynamoCostNetwork + cfg.dynamoCostReplication + cfg.dynamoDaxCost;

const scyllaResult = calculateScyllaCosts();

const savings = cfg.dynamoCostTotal / 2;
const costRatio = (cfg.dynamoCostTotal / scyllaResult.scyllaCost).toFixed(1);

document.getElementById('costDiff').textContent = `$${formatNumber(savings)}`;

logCosts(scyllaResult, costRatio);
}

0 comments on commit e747740

Please sign in to comment.