diff --git a/cost/aws/ec2_compute_optimizer/CHANGELOG.md b/cost/aws/ec2_compute_optimizer/CHANGELOG.md index 4dc6f78b2c..a3170e88bc 100644 --- a/cost/aws/ec2_compute_optimizer/CHANGELOG.md +++ b/cost/aws/ec2_compute_optimizer/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.3.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.3.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/aws/ec2_compute_optimizer/aws_ec2_compute_optimizer.pt b/cost/aws/ec2_compute_optimizer/aws_ec2_compute_optimizer.pt index a78a911a84..b3f546319f 100644 --- a/cost/aws/ec2_compute_optimizer/aws_ec2_compute_optimizer.pt +++ b/cost/aws/ec2_compute_optimizer/aws_ec2_compute_optimizer.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.3.1", + version: "0.3.2", provider: "AWS", service: "Compute", policy_set: "Rightsize Compute Instances", @@ -614,21 +614,28 @@ script "js_recommendations_merged", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } instance_table = {} diff --git a/cost/aws/extended_support/CHANGELOG.md b/cost/aws/extended_support/CHANGELOG.md index 3b9059b163..d97307ca05 100644 --- a/cost/aws/extended_support/CHANGELOG.md +++ b/cost/aws/extended_support/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.2.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.2.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/aws/extended_support/aws_extended_support.pt b/cost/aws/extended_support/aws_extended_support.pt index 7afd6553ff..f94658b7be 100644 --- a/cost/aws/extended_support/aws_extended_support.pt +++ b/cost/aws/extended_support/aws_extended_support.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.2.1", + version: "0.2.2", provider: "AWS", service: "All", policy_set: "Deprecated Resources", @@ -329,21 +329,28 @@ script "js_extended_support_resources", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } // Store Billing Center names to match them with their id diff --git a/cost/aws/idle_nat_gateways/CHANGELOG.md b/cost/aws/idle_nat_gateways/CHANGELOG.md index 74a3156afd..4d4ad3e086 100644 --- a/cost/aws/idle_nat_gateways/CHANGELOG.md +++ b/cost/aws/idle_nat_gateways/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.1.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.1.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/aws/idle_nat_gateways/aws_idle_nat_gateways.pt b/cost/aws/idle_nat_gateways/aws_idle_nat_gateways.pt index 2342fed50c..3c0e62741b 100644 --- a/cost/aws/idle_nat_gateways/aws_idle_nat_gateways.pt +++ b/cost/aws/idle_nat_gateways/aws_idle_nat_gateways.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.1.1", + version: "0.1.2", provider: "AWS", service: "Network", policy_set: "Idle NAT Gateways", @@ -594,21 +594,28 @@ script "js_idle_gateways", type:"javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/aws/old_snapshots/CHANGELOG.md b/cost/aws/old_snapshots/CHANGELOG.md index 4a057226d8..94f90034ae 100644 --- a/cost/aws/old_snapshots/CHANGELOG.md +++ b/cost/aws/old_snapshots/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v8.4.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v8.4.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/aws/old_snapshots/aws_delete_old_snapshots.pt b/cost/aws/old_snapshots/aws_delete_old_snapshots.pt index 5a4d60276a..c6ff9cd75b 100644 --- a/cost/aws/old_snapshots/aws_delete_old_snapshots.pt +++ b/cost/aws/old_snapshots/aws_delete_old_snapshots.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "8.4.1", + version: "8.4.2", provider: "AWS", service: "Storage", policy_set: "Old Snapshots", @@ -923,21 +923,27 @@ script "js_snapshots_cost_mapping", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/aws/reserved_instances/recommendations/CHANGELOG.md b/cost/aws/reserved_instances/recommendations/CHANGELOG.md index f5616d3e0a..347f41cd79 100644 --- a/cost/aws/reserved_instances/recommendations/CHANGELOG.md +++ b/cost/aws/reserved_instances/recommendations/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v3.6.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v3.6.0 - Added support for DynamoDB and MemoryDB reservation recommendations diff --git a/cost/aws/reserved_instances/recommendations/aws_reserved_instance_recommendations.pt b/cost/aws/reserved_instances/recommendations/aws_reserved_instance_recommendations.pt index bef34df4bd..69aea8b332 100644 --- a/cost/aws/reserved_instances/recommendations/aws_reserved_instance_recommendations.pt +++ b/cost/aws/reserved_instances/recommendations/aws_reserved_instance_recommendations.pt @@ -7,7 +7,7 @@ severity "medium" category "Cost" default_frequency "weekly" info( - version: "3.6.0", + version: "3.6.1", provider: "AWS", service: "Compute", policy_set: "Reserved Instances", @@ -486,21 +486,28 @@ script "js_ri_normalization", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/aws/rightsize_ebs_volumes/CHANGELOG.md b/cost/aws/rightsize_ebs_volumes/CHANGELOG.md index 8ed40fc774..7fe444f2b6 100644 --- a/cost/aws/rightsize_ebs_volumes/CHANGELOG.md +++ b/cost/aws/rightsize_ebs_volumes/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.3.3 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.3.2 - Added `hide_skip_approvals` field to the info section, enabling the UI to dynamically show or hide the "Skip Approval" option. Functionality unchanged. diff --git a/cost/aws/rightsize_ebs_volumes/aws_rightsize_ebs_volumes.pt b/cost/aws/rightsize_ebs_volumes/aws_rightsize_ebs_volumes.pt index eb55b63203..7cf1be8abf 100644 --- a/cost/aws/rightsize_ebs_volumes/aws_rightsize_ebs_volumes.pt +++ b/cost/aws/rightsize_ebs_volumes/aws_rightsize_ebs_volumes.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.3.2", + version: "0.3.3", provider: "AWS", service: "EBS", policy_set: "Unused Volumes", @@ -1070,21 +1070,28 @@ script "js_volume_cost_mapping", type:"javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } // Grab just the lists of volumes we need from the datasource results diff --git a/cost/aws/rightsize_ec2_instances/CHANGELOG.md b/cost/aws/rightsize_ec2_instances/CHANGELOG.md index 7c529d87d0..3ae0342f4a 100644 --- a/cost/aws/rightsize_ec2_instances/CHANGELOG.md +++ b/cost/aws/rightsize_ec2_instances/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v5.3.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v5.3.1 - Added `hide_skip_approvals` field to the info section, enabling the UI to dynamically show or hide the "Skip Approval" option. Functionality unchanged. diff --git a/cost/aws/rightsize_ec2_instances/aws_rightsize_ec2_instances.pt b/cost/aws/rightsize_ec2_instances/aws_rightsize_ec2_instances.pt index fd5445c3f9..c03be6a291 100644 --- a/cost/aws/rightsize_ec2_instances/aws_rightsize_ec2_instances.pt +++ b/cost/aws/rightsize_ec2_instances/aws_rightsize_ec2_instances.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "5.3.1", + version: "5.3.2", provider: "AWS", service: "Compute", policy_set: "Rightsize Compute Instances", @@ -1006,21 +1006,28 @@ script "js_idle_and_underutil_instances", type:"javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } // The key name is lowercase, param value needs to be lowercase. diff --git a/cost/aws/rightsize_elasticache/CHANGELOG.md b/cost/aws/rightsize_elasticache/CHANGELOG.md index 183b29c966..fe18149af3 100644 --- a/cost/aws/rightsize_elasticache/CHANGELOG.md +++ b/cost/aws/rightsize_elasticache/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.2.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.2.1 - Added `hide_skip_approvals` field to the info section, enabling the UI to dynamically show or hide the "Skip Approval" option. Functionality unchanged. diff --git a/cost/aws/rightsize_elasticache/aws_rightsize_elasticache.pt b/cost/aws/rightsize_elasticache/aws_rightsize_elasticache.pt index 4148bb4d0c..f0037fff9a 100644 --- a/cost/aws/rightsize_elasticache/aws_rightsize_elasticache.pt +++ b/cost/aws/rightsize_elasticache/aws_rightsize_elasticache.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.2.1", + version: "0.2.2", provider: "AWS", service: "Database", policy_set: "Rightsize Database Instances", @@ -984,21 +984,28 @@ script "js_underutilized_elasticache_clusters", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/aws/rightsize_rds_instances/CHANGELOG.md b/cost/aws/rightsize_rds_instances/CHANGELOG.md index 8f8dac37ed..22059eb04c 100644 --- a/cost/aws/rightsize_rds_instances/CHANGELOG.md +++ b/cost/aws/rightsize_rds_instances/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v5.5.3 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v5.5.2 - Added `hide_skip_approvals` field to the info section, enabling the UI to dynamically show or hide the "Skip Approval" option. Functionality unchanged. diff --git a/cost/aws/rightsize_rds_instances/aws_rightsize_rds_instances.pt b/cost/aws/rightsize_rds_instances/aws_rightsize_rds_instances.pt index 8e32ea5639..b7f93aa16f 100644 --- a/cost/aws/rightsize_rds_instances/aws_rightsize_rds_instances.pt +++ b/cost/aws/rightsize_rds_instances/aws_rightsize_rds_instances.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "5.5.2", + version: "5.5.3", provider: "AWS", service: "RDS", policy_set: "Rightsize Database Instances", @@ -1434,21 +1434,28 @@ script "js_rds_idle_incident", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] @@ -1556,21 +1563,28 @@ script "js_rds_underutil_incident", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/aws/rightsize_redshift/CHANGELOG.md b/cost/aws/rightsize_redshift/CHANGELOG.md index 6697b0855b..7e575feed5 100644 --- a/cost/aws/rightsize_redshift/CHANGELOG.md +++ b/cost/aws/rightsize_redshift/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.1.3 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.1.2 - Added `hide_skip_approvals` field to the info section, enabling the UI to dynamically show or hide the "Skip Approval" option. Functionality unchanged. diff --git a/cost/aws/rightsize_redshift/aws_rightsize_redshift.pt b/cost/aws/rightsize_redshift/aws_rightsize_redshift.pt index 88abade9d3..e88736cb02 100644 --- a/cost/aws/rightsize_redshift/aws_rightsize_redshift.pt +++ b/cost/aws/rightsize_redshift/aws_rightsize_redshift.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.1.2", + version: "0.1.3", provider: "AWS", service: "Database", policy_set: "Rightsize Database Instances", @@ -874,21 +874,28 @@ script "js_underutilized_redshift_clusters", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/aws/savings_plan/recommendations/CHANGELOG.md b/cost/aws/savings_plan/recommendations/CHANGELOG.md index 092b03eda0..5015cf9fdf 100644 --- a/cost/aws/savings_plan/recommendations/CHANGELOG.md +++ b/cost/aws/savings_plan/recommendations/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v3.3.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v3.3.0 - Removed invalid "Any" option from the `Savings Plan Term` parameter. diff --git a/cost/aws/savings_plan/recommendations/aws_savings_plan_recommendations.pt b/cost/aws/savings_plan/recommendations/aws_savings_plan_recommendations.pt index e93219e7db..ff40b11b7a 100644 --- a/cost/aws/savings_plan/recommendations/aws_savings_plan_recommendations.pt +++ b/cost/aws/savings_plan/recommendations/aws_savings_plan_recommendations.pt @@ -7,7 +7,7 @@ severity "medium" category "Cost" default_frequency "weekly" info( - version: "3.3.0", + version: "3.3.1", provider: "AWS", service: "Compute", policy_set: "Savings Plans", @@ -396,21 +396,28 @@ script "js_sp_normalization", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } service_table = { diff --git a/cost/aws/savings_plan/utilization/CHANGELOG.md b/cost/aws/savings_plan/utilization/CHANGELOG.md index fe76bb927c..462cc635d5 100644 --- a/cost/aws/savings_plan/utilization/CHANGELOG.md +++ b/cost/aws/savings_plan/utilization/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v4.0.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v4.0.0 - Policy can now be run against an arbitrary number of days in the past diff --git a/cost/aws/savings_plan/utilization/aws_savings_plan_utilization.pt b/cost/aws/savings_plan/utilization/aws_savings_plan_utilization.pt index 03a30b2d42..cf0c266145 100644 --- a/cost/aws/savings_plan/utilization/aws_savings_plan_utilization.pt +++ b/cost/aws/savings_plan/utilization/aws_savings_plan_utilization.pt @@ -7,7 +7,7 @@ severity "medium" category "Cost" default_frequency "monthly" info( - version: "4.0.0", + version: "4.0.1", provider: "AWS", service: "Compute", policy_set: "Savings Plans" @@ -259,21 +259,27 @@ script "js_chart_data", type: "javascript" do code <<-EOS // Function for formatting currency numbers later function formatNumber(number, separator) { - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } end_date = new Date() diff --git a/cost/aws/superseded_ebs_volumes/CHANGELOG.md b/cost/aws/superseded_ebs_volumes/CHANGELOG.md index aa3ef3498a..084afe1f6a 100644 --- a/cost/aws/superseded_ebs_volumes/CHANGELOG.md +++ b/cost/aws/superseded_ebs_volumes/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v6.3.4 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v6.3.3 - Fixed issue where Currency Conversion messaging in policy incident would show incorrectly. Functionality unchanged. diff --git a/cost/aws/superseded_ebs_volumes/aws_superseded_ebs_volumes.pt b/cost/aws/superseded_ebs_volumes/aws_superseded_ebs_volumes.pt index 6db75d1943..052d5904c5 100644 --- a/cost/aws/superseded_ebs_volumes/aws_superseded_ebs_volumes.pt +++ b/cost/aws/superseded_ebs_volumes/aws_superseded_ebs_volumes.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "6.3.3", + version: "6.3.4", provider: "AWS", service: "Compute", policy_set: "Inefficient Disk Usage", @@ -914,21 +914,28 @@ script "js_underutil_volumes", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/aws/superseded_instances/CHANGELOG.md b/cost/aws/superseded_instances/CHANGELOG.md index 70bdfe07c2..5b01aefd07 100644 --- a/cost/aws/superseded_instances/CHANGELOG.md +++ b/cost/aws/superseded_instances/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v2.3.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v2.3.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/aws/superseded_instances/aws_superseded_instances.pt b/cost/aws/superseded_instances/aws_superseded_instances.pt index 0152b6bdcb..67507f785d 100644 --- a/cost/aws/superseded_instances/aws_superseded_instances.pt +++ b/cost/aws/superseded_instances/aws_superseded_instances.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "2.3.1", + version: "2.3.2", provider: "AWS", service: "Compute", policy_set: "Superseded Compute Instances", @@ -677,21 +677,28 @@ script "js_superseded_instances", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/aws/unused_albs/CHANGELOG.md b/cost/aws/unused_albs/CHANGELOG.md index 970f837b64..affcf0d6e2 100644 --- a/cost/aws/unused_albs/CHANGELOG.md +++ b/cost/aws/unused_albs/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.2.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.2.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/aws/unused_albs/aws_unused_albs.pt b/cost/aws/unused_albs/aws_unused_albs.pt index dd7159242d..cd5d94982d 100644 --- a/cost/aws/unused_albs/aws_unused_albs.pt +++ b/cost/aws/unused_albs/aws_unused_albs.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.2.1", + version: "0.2.2", provider: "AWS", service: "Network", policy_set: "Unused Load Balancers", @@ -809,21 +809,28 @@ script "js_bad_albs", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/aws/unused_clbs/CHANGELOG.md b/cost/aws/unused_clbs/CHANGELOG.md index 7236654058..233ac30d52 100644 --- a/cost/aws/unused_clbs/CHANGELOG.md +++ b/cost/aws/unused_clbs/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v6.4.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v6.4.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/aws/unused_clbs/aws_unused_clbs.pt b/cost/aws/unused_clbs/aws_unused_clbs.pt index 313f97c2a0..f15c28019c 100644 --- a/cost/aws/unused_clbs/aws_unused_clbs.pt +++ b/cost/aws/unused_clbs/aws_unused_clbs.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "6.4.1", + version: "6.4.2", provider: "AWS", service: "Network", policy_set: "Unused Load Balancers", @@ -680,21 +680,28 @@ script "js_unused_clb_cost_mapping", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/aws/unused_ip_addresses/CHANGELOG.md b/cost/aws/unused_ip_addresses/CHANGELOG.md index 2faa42cd83..c378986808 100644 --- a/cost/aws/unused_ip_addresses/CHANGELOG.md +++ b/cost/aws/unused_ip_addresses/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v9.2.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v9.2.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/aws/unused_ip_addresses/aws_unused_ip_addresses.pt b/cost/aws/unused_ip_addresses/aws_unused_ip_addresses.pt index 8a1f6954ae..0a04be1412 100644 --- a/cost/aws/unused_ip_addresses/aws_unused_ip_addresses.pt +++ b/cost/aws/unused_ip_addresses/aws_unused_ip_addresses.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "9.2.1", + version: "9.2.2", provider: "AWS", service: "Compute", policy_set: "Unused IP Addresses", @@ -646,21 +646,27 @@ script "js_ip_cost_mapping", type:"javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/aws/unused_nlbs/CHANGELOG.md b/cost/aws/unused_nlbs/CHANGELOG.md index 970f837b64..affcf0d6e2 100644 --- a/cost/aws/unused_nlbs/CHANGELOG.md +++ b/cost/aws/unused_nlbs/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.2.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.2.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/aws/unused_nlbs/aws_unused_nlbs.pt b/cost/aws/unused_nlbs/aws_unused_nlbs.pt index 5b9083363e..a877a56201 100644 --- a/cost/aws/unused_nlbs/aws_unused_nlbs.pt +++ b/cost/aws/unused_nlbs/aws_unused_nlbs.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.2.1", + version: "0.2.2", provider: "AWS", service: "Network", policy_set: "Unused Load Balancers", @@ -809,21 +809,28 @@ script "js_bad_nlbs", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/aws/unused_volumes/CHANGELOG.md b/cost/aws/unused_volumes/CHANGELOG.md index 3ad153e1a8..2e6ecf4eb6 100644 --- a/cost/aws/unused_volumes/CHANGELOG.md +++ b/cost/aws/unused_volumes/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v8.3.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v8.3.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/aws/unused_volumes/aws_delete_unused_volumes.pt b/cost/aws/unused_volumes/aws_delete_unused_volumes.pt index 74fb0c40b5..1320e3f87f 100644 --- a/cost/aws/unused_volumes/aws_delete_unused_volumes.pt +++ b/cost/aws/unused_volumes/aws_delete_unused_volumes.pt @@ -8,7 +8,7 @@ severity "low" default_frequency "weekly" info( deprecated: "true", - version: "8.3.1", + version: "8.3.2", provider: "AWS", service: "EBS", policy_set: "Unused Volumes", @@ -852,21 +852,28 @@ script "js_volume_cost_mapping", type:"javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/advisor_compute/CHANGELOG.md b/cost/azure/advisor_compute/CHANGELOG.md index a1ed544621..8974b46b62 100644 --- a/cost/azure/advisor_compute/CHANGELOG.md +++ b/cost/azure/advisor_compute/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.1.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.1.0 - Initial release diff --git a/cost/azure/advisor_compute/azure_advisor_compute.pt b/cost/azure/advisor_compute/azure_advisor_compute.pt index 1a5cea99fc..50d342d335 100644 --- a/cost/azure/advisor_compute/azure_advisor_compute.pt +++ b/cost/azure/advisor_compute/azure_advisor_compute.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.1.0", + version: "0.1.1", provider: "Azure", service: "Compute", policy_set: "Rightsize Compute Instances", @@ -637,21 +637,28 @@ script "js_recommendations_merged", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } vm_table = {} diff --git a/cost/azure/hybrid_use_benefit/CHANGELOG.md b/cost/azure/hybrid_use_benefit/CHANGELOG.md index 6c62170803..5688a160d8 100644 --- a/cost/azure/hybrid_use_benefit/CHANGELOG.md +++ b/cost/azure/hybrid_use_benefit/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v5.2.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v5.2.1 - Fixed issue where policy actions were not properly reporting errors diff --git a/cost/azure/hybrid_use_benefit/azure_hybrid_use_benefit.pt b/cost/azure/hybrid_use_benefit/azure_hybrid_use_benefit.pt index 72f386743b..8a07b09d67 100644 --- a/cost/azure/hybrid_use_benefit/azure_hybrid_use_benefit.pt +++ b/cost/azure/hybrid_use_benefit/azure_hybrid_use_benefit.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "daily" info( - version: "5.2.1", + version: "5.2.2", provider: "Azure", service: "Compute", policy_set: "Hybrid Use Benefit", @@ -677,24 +677,30 @@ end script "js_ahub_recommendations", type: "javascript" do parameters "ds_instance_costs_grouped", "ds_azure_instances_region_filtered", "ds_region_table", "ds_azure_pricing", "ds_currency", "ds_applied_policy", "param_min_savings" result "result" - code <<-EOS - // Function for formatting currency numbers later + code <<-'EOS' + // Function for formatting currency numbers function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + formatted_number = withSeparator + } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] @@ -800,12 +806,7 @@ script "js_ahub_recommendations", type: "javascript" do do_verb, " not have it applied." ].join('') - savings_message = [ - ds_currency['symbol'], ' ', - formatNumber(parseFloat(total_savings).toFixed(2), ds_currency['t_separator']) - ].join('') - - result = _.sortBy(result, function(item) { return item['savings'] * -1 }) + result = _.sortBy(result, 'savings').reverse() // Dummy item to ensure that the check statement in the policy executes at least once result.push({ @@ -832,7 +833,7 @@ script "js_ahub_recommendations", type: "javascript" do message: "" }) - result[0]['total_savings'] = savings_message + result[0]['total_savings'] = ds_currency['symbol'] + " " + formatNumber(total_savings, ds_currency['t_separator']) result[0]['message'] = findings EOS end diff --git a/cost/azure/hybrid_use_benefit_linux/CHANGELOG.md b/cost/azure/hybrid_use_benefit_linux/CHANGELOG.md index 95fdebbfa5..88e23cc030 100644 --- a/cost/azure/hybrid_use_benefit_linux/CHANGELOG.md +++ b/cost/azure/hybrid_use_benefit_linux/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v5.1.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v5.1.1 - Fixed issue where policy actions were not properly reporting errors diff --git a/cost/azure/hybrid_use_benefit_linux/ahub_linux.pt b/cost/azure/hybrid_use_benefit_linux/ahub_linux.pt index 081b7b326a..6653a840ee 100644 --- a/cost/azure/hybrid_use_benefit_linux/ahub_linux.pt +++ b/cost/azure/hybrid_use_benefit_linux/ahub_linux.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "daily" info( - version: "5.1.1", + version: "5.1.2", provider: "Azure", service: "Compute", policy_set: "Hybrid Use Benefit" @@ -545,21 +545,27 @@ script "js_ahub_recommendations", type: "javascript" do code <<-EOS // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/old_snapshots/CHANGELOG.md b/cost/azure/old_snapshots/CHANGELOG.md index eba5ec8c44..a58cb4be4a 100644 --- a/cost/azure/old_snapshots/CHANGELOG.md +++ b/cost/azure/old_snapshots/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v7.2.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v7.2.0 - Modified internal names for incident fields for more accurate scraping into Optimization dashboard diff --git a/cost/azure/old_snapshots/azure_delete_old_snapshots.pt b/cost/azure/old_snapshots/azure_delete_old_snapshots.pt index cc1dcda0b9..431358eb86 100644 --- a/cost/azure/old_snapshots/azure_delete_old_snapshots.pt +++ b/cost/azure/old_snapshots/azure_delete_old_snapshots.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "7.2.0", + version: "7.2.1", provider: "Azure", service: "Storage", policy_set: "Old Snapshots", @@ -593,21 +593,27 @@ script "js_azure_snapshots_incident", type:"javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/reserved_instances/recommendations/CHANGELOG.md b/cost/azure/reserved_instances/recommendations/CHANGELOG.md index 6a81a1a683..8a0d70dc5f 100644 --- a/cost/azure/reserved_instances/recommendations/CHANGELOG.md +++ b/cost/azure/reserved_instances/recommendations/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v4.1.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v4.1.0 - Updated Azure API versions to provide more up to date and accurate results diff --git a/cost/azure/reserved_instances/recommendations/azure_reserved_instance_recommendations.pt b/cost/azure/reserved_instances/recommendations/azure_reserved_instance_recommendations.pt index bf866e7c1d..4c991386c0 100644 --- a/cost/azure/reserved_instances/recommendations/azure_reserved_instance_recommendations.pt +++ b/cost/azure/reserved_instances/recommendations/azure_reserved_instance_recommendations.pt @@ -7,7 +7,7 @@ severity "medium" category "Cost" default_frequency "weekly" info( - version: "4.1.0", + version: "4.1.1", provider: "Azure", service: "Compute", policy_set: "Reserved Instances", @@ -580,21 +580,28 @@ script "js_ri_incident", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/reserved_instances/utilization/CHANGELOG.md b/cost/azure/reserved_instances/utilization/CHANGELOG.md index 1b9902e189..2ad79f6416 100644 --- a/cost/azure/reserved_instances/utilization/CHANGELOG.md +++ b/cost/azure/reserved_instances/utilization/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v3.1.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v3.1.1 - Fixed Microsoft VM Size Flexibility URL which prevented the policy from completing without error. Policy functionality is unchanged. diff --git a/cost/azure/reserved_instances/utilization/azure_reserved_instance_utilization.pt b/cost/azure/reserved_instances/utilization/azure_reserved_instance_utilization.pt index 5eb5a0ceb8..76d733ab90 100644 --- a/cost/azure/reserved_instances/utilization/azure_reserved_instance_utilization.pt +++ b/cost/azure/reserved_instances/utilization/azure_reserved_instance_utilization.pt @@ -7,7 +7,7 @@ severity "medium" category "Cost" default_frequency "weekly" info( - version: "3.1.1", + version: "3.1.2", provider: "Azure", service: "Compute", policy_set: "" @@ -391,7 +391,7 @@ end datasource "ds_reservation_summaries" do iterate $ds_billing_account_lookback_period_combinations request do - run_script $js_reservation_summaries, val(iter_item, "billingAccountId"), val(iter_item, "agreementType"), val(iter_item, "lookbackPeriodDateRange"), $param_azure_endpoint + run_script $js_reservation_summaries, val(iter_item, "billingAccountId"), val(iter_item, "agreementType"), val(iter_item, "lookbackPeriodDateRange"), $param_azure_endpoint end result do encoding "json" @@ -527,21 +527,27 @@ script "js_reservation_purchase_details", type: "javascript" do //function for formatting spend number function formatNumber(number, separator) { - var numString = number.toString(); - var values = numString.split("."); - var result = '' - while ( values[0].length > 3 ) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - result = separator + chunk + result - } - if ( values[0].length > 0 ) { - result = values[0] + result - } - if ( values[1] == undefined ) { - return result; + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } } - return result + "." + values[1]; + + return formatted_number } //format costs with currency symbol and thousands separator diff --git a/cost/azure/rightsize_compute_instances/CHANGELOG.md b/cost/azure/rightsize_compute_instances/CHANGELOG.md index 5cf6b2e6ac..12fc48c75d 100644 --- a/cost/azure/rightsize_compute_instances/CHANGELOG.md +++ b/cost/azure/rightsize_compute_instances/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v6.0.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v6.0.0 - Recommendations now consider number of attached data disks. Sizes that would not support the current number of attached disks for an instance will not be recommended. diff --git a/cost/azure/rightsize_compute_instances/azure_compute_rightsizing.pt b/cost/azure/rightsize_compute_instances/azure_compute_rightsizing.pt index d35e75b92e..27c1883316 100644 --- a/cost/azure/rightsize_compute_instances/azure_compute_rightsizing.pt +++ b/cost/azure/rightsize_compute_instances/azure_compute_rightsizing.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "6.0.0", + version: "6.0.1", provider: "Azure", service: "Compute", policy_set: "Rightsize Compute Instances", @@ -1132,21 +1132,28 @@ script "js_idle_and_underutil_instances", type:"javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } // The key name is lowercase, param value needs to be lowercase. diff --git a/cost/azure/rightsize_managed_sql/CHANGELOG.md b/cost/azure/rightsize_managed_sql/CHANGELOG.md index 164b00517d..434361c5c1 100644 --- a/cost/azure/rightsize_managed_sql/CHANGELOG.md +++ b/cost/azure/rightsize_managed_sql/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.3.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.3.0 - Added support for downsizing multiple sizes where appropriate diff --git a/cost/azure/rightsize_managed_sql/azure_rightsize_managed_sql.pt b/cost/azure/rightsize_managed_sql/azure_rightsize_managed_sql.pt index 9a81158f04..85f28955ea 100644 --- a/cost/azure/rightsize_managed_sql/azure_rightsize_managed_sql.pt +++ b/cost/azure/rightsize_managed_sql/azure_rightsize_managed_sql.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.3.0", + version: "0.3.1", provider: "Azure", service: "SQL", policy_set: "Rightsize Database Instances", @@ -861,21 +861,27 @@ script "js_downsize_sql_incident", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/rightsize_managed_sql_storage/CHANGELOG.md b/cost/azure/rightsize_managed_sql_storage/CHANGELOG.md index db2ffc8934..7bd6791505 100644 --- a/cost/azure/rightsize_managed_sql_storage/CHANGELOG.md +++ b/cost/azure/rightsize_managed_sql_storage/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.2.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.2.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/azure/rightsize_managed_sql_storage/azure_rightsize_managed_sql_storage.pt b/cost/azure/rightsize_managed_sql_storage/azure_rightsize_managed_sql_storage.pt index 765c556287..847b95d676 100644 --- a/cost/azure/rightsize_managed_sql_storage/azure_rightsize_managed_sql_storage.pt +++ b/cost/azure/rightsize_managed_sql_storage/azure_rightsize_managed_sql_storage.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.2.1", + version: "0.2.2", provider: "Azure", service: "SQL", policy_set: "Rightsize Database Instances", @@ -607,21 +607,28 @@ script "js_azure_sql_instances_incident", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/rightsize_mysql_flexible/CHANGELOG.md b/cost/azure/rightsize_mysql_flexible/CHANGELOG.md index 37c9baf6d1..8812cfe5a6 100644 --- a/cost/azure/rightsize_mysql_flexible/CHANGELOG.md +++ b/cost/azure/rightsize_mysql_flexible/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.2.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.2.0 - Added support for downsizing multiple sizes where appropriate diff --git a/cost/azure/rightsize_mysql_flexible/azure_rightsize_mysql_flexible.pt b/cost/azure/rightsize_mysql_flexible/azure_rightsize_mysql_flexible.pt index edb30adced..3d32609abc 100644 --- a/cost/azure/rightsize_mysql_flexible/azure_rightsize_mysql_flexible.pt +++ b/cost/azure/rightsize_mysql_flexible/azure_rightsize_mysql_flexible.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.2.0", + version: "0.2.1", provider: "Azure", service: "MySQL", policy_set: "Rightsize Database Instances", @@ -898,21 +898,27 @@ script "js_downsize_mysql_incident", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] @@ -1069,21 +1075,27 @@ script "js_unused_mysql_incident", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/rightsize_mysql_single/CHANGELOG.md b/cost/azure/rightsize_mysql_single/CHANGELOG.md index 37c9baf6d1..8812cfe5a6 100644 --- a/cost/azure/rightsize_mysql_single/CHANGELOG.md +++ b/cost/azure/rightsize_mysql_single/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.2.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.2.0 - Added support for downsizing multiple sizes where appropriate diff --git a/cost/azure/rightsize_mysql_single/azure_rightsize_mysql_single.pt b/cost/azure/rightsize_mysql_single/azure_rightsize_mysql_single.pt index 5f7f1c636b..4dc3a1e836 100644 --- a/cost/azure/rightsize_mysql_single/azure_rightsize_mysql_single.pt +++ b/cost/azure/rightsize_mysql_single/azure_rightsize_mysql_single.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.2.0", + version: "0.2.1", provider: "Azure", service: "MySQL", policy_set: "Rightsize Database Instances", @@ -893,21 +893,27 @@ script "js_downsize_mysql_incident", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] @@ -1062,21 +1068,27 @@ script "js_unused_mysql_incident", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/rightsize_netapp/CHANGELOG.md b/cost/azure/rightsize_netapp/CHANGELOG.md index a3c9bf6eab..a1148b409b 100644 --- a/cost/azure/rightsize_netapp/CHANGELOG.md +++ b/cost/azure/rightsize_netapp/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v2.0.3 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v2.0.2 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/azure/rightsize_netapp/azure_rightsize_netapp.pt b/cost/azure/rightsize_netapp/azure_rightsize_netapp.pt index 1f3bb11347..17cfb0a943 100644 --- a/cost/azure/rightsize_netapp/azure_rightsize_netapp.pt +++ b/cost/azure/rightsize_netapp/azure_rightsize_netapp.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "2.0.2", + version: "2.0.3", provider: "Azure", service: "NetApp Files", policy_set: "Rightsize Storage", @@ -902,20 +902,27 @@ script "js_naf_oversized_volumes", type: "javascript" do } function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } function bytesToGibibytes(bytes) { return Math.ceil(bytes * 9.3132257461548e-10) } diff --git a/cost/azure/rightsize_sql_instances/CHANGELOG.md b/cost/azure/rightsize_sql_instances/CHANGELOG.md index 34fe806fb2..648a5b2fde 100644 --- a/cost/azure/rightsize_sql_instances/CHANGELOG.md +++ b/cost/azure/rightsize_sql_instances/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v5.5.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v5.5.0 - Added support for downsizing multiple sizes where appropriate diff --git a/cost/azure/rightsize_sql_instances/azure_rightsize_sql_instances.pt b/cost/azure/rightsize_sql_instances/azure_rightsize_sql_instances.pt index 9da210e56e..d87caeb3f5 100644 --- a/cost/azure/rightsize_sql_instances/azure_rightsize_sql_instances.pt +++ b/cost/azure/rightsize_sql_instances/azure_rightsize_sql_instances.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "5.5.0", + version: "5.5.1", provider: "Azure", service: "SQL", policy_set: "Rightsize Database Instances", @@ -972,21 +972,27 @@ script "js_downsize_sql_incident", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] @@ -1145,21 +1151,27 @@ script "js_unused_sql_incident", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/rightsize_sql_storage/CHANGELOG.md b/cost/azure/rightsize_sql_storage/CHANGELOG.md index 74a3156afd..4d4ad3e086 100644 --- a/cost/azure/rightsize_sql_storage/CHANGELOG.md +++ b/cost/azure/rightsize_sql_storage/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.1.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.1.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/azure/rightsize_sql_storage/azure_rightsize_sql_storage.pt b/cost/azure/rightsize_sql_storage/azure_rightsize_sql_storage.pt index 0d8776bf61..0378b3c806 100644 --- a/cost/azure/rightsize_sql_storage/azure_rightsize_sql_storage.pt +++ b/cost/azure/rightsize_sql_storage/azure_rightsize_sql_storage.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.1.1", + version: "0.1.2", provider: "Azure", service: "SQL", policy_set: "Rightsize Database Instances", @@ -796,21 +796,28 @@ script "js_azure_sql_storage_incident", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/rightsize_synapse_sql_pools/CHANGELOG.md b/cost/azure/rightsize_synapse_sql_pools/CHANGELOG.md index 70fa8b869f..82658677a2 100644 --- a/cost/azure/rightsize_synapse_sql_pools/CHANGELOG.md +++ b/cost/azure/rightsize_synapse_sql_pools/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.1.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.1.0 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/azure/rightsize_synapse_sql_pools/azure_rightsize_synapse_sql_pools.pt b/cost/azure/rightsize_synapse_sql_pools/azure_rightsize_synapse_sql_pools.pt index a98e4c21e4..11e3661ff8 100644 --- a/cost/azure/rightsize_synapse_sql_pools/azure_rightsize_synapse_sql_pools.pt +++ b/cost/azure/rightsize_synapse_sql_pools/azure_rightsize_synapse_sql_pools.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.1.0", + version: "0.1.1", provider: "Azure", service: "SQL", policy_set: "Rightsize Synapse SQL Pools", @@ -804,20 +804,27 @@ script "js_azure_synapse_underutil_and_idle_pools", type: "javascript" do code <<-EOS // Used for formatting numbers to look pretty function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } // Returns an array of single values sorted. diff --git a/cost/azure/savings_plan/recommendations/CHANGELOG.md b/cost/azure/savings_plan/recommendations/CHANGELOG.md index 36f563e189..bc220ccb48 100644 --- a/cost/azure/savings_plan/recommendations/CHANGELOG.md +++ b/cost/azure/savings_plan/recommendations/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v3.1.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v3.1.0 - Updated Azure API versions to provide more up to date and accurate results diff --git a/cost/azure/savings_plan/recommendations/azure_savings_plan_recommendations.pt b/cost/azure/savings_plan/recommendations/azure_savings_plan_recommendations.pt index 04b75a4337..9cc1405109 100644 --- a/cost/azure/savings_plan/recommendations/azure_savings_plan_recommendations.pt +++ b/cost/azure/savings_plan/recommendations/azure_savings_plan_recommendations.pt @@ -7,7 +7,7 @@ severity "medium" category "Cost" default_frequency "weekly" info( - version: "3.1.0", + version: "3.1.1", provider: "Azure", service: "Compute", policy_set: "Savings Plans", @@ -429,21 +429,28 @@ script "js_sp_incident", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/savings_plan/utilization/CHANGELOG.md b/cost/azure/savings_plan/utilization/CHANGELOG.md index a1ed544621..8974b46b62 100644 --- a/cost/azure/savings_plan/utilization/CHANGELOG.md +++ b/cost/azure/savings_plan/utilization/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.1.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.1.0 - Initial release diff --git a/cost/azure/savings_plan/utilization/azure_savings_plan_utilization.pt b/cost/azure/savings_plan/utilization/azure_savings_plan_utilization.pt index fe3add5dad..8123361334 100644 --- a/cost/azure/savings_plan/utilization/azure_savings_plan_utilization.pt +++ b/cost/azure/savings_plan/utilization/azure_savings_plan_utilization.pt @@ -7,7 +7,7 @@ severity "medium" category "Cost" default_frequency "monthly" info( - version: "0.1.0", + version: "0.1.1", provider: "Azure", service: "Compute", policy_set: "Savings Plans" @@ -204,7 +204,7 @@ datasource "ds_savings_plan_details" do field "agreementType", val(iter_item, "agreementType") field "savingsPlanOrderId", jmes_path(col_item, "id") field "savingsPlanOrderName", jmes_path(col_item, "name") - end + end end end @@ -296,12 +296,12 @@ script "js_filtered_savings_plans", type: "javascript" do // Applied Scope Properties if (sp.scopeProperties) { if (sp.scopeProperties.managementGroupId) { - sp["scopeDetailId"] = sp.scopeProperties.managementGroupId - sp["scopeDetailName"] = sp.scopeProperties.displayName + sp["scopeDetailId"] = sp.scopeProperties.managementGroupId + sp["scopeDetailName"] = sp.scopeProperties.displayName } else if (sp.scopeProperties.subscriptionId) { - sp["scopeDetailId"] = sp.scopeProperties.subscriptionId - sp["scopeDetailName"] = sp.scopeProperties.displayName - } + sp["scopeDetailId"] = sp.scopeProperties.subscriptionId + sp["scopeDetailName"] = sp.scopeProperties.displayName + } sp = _.omit(sp, "scopeProperties") } else { @@ -314,7 +314,7 @@ script "js_filtered_savings_plans", type: "javascript" do if (sp.utilization.trend) { sp["utilizationTrend"] = sp.utilization.trend } - + if (_.size(sp.utilization.aggregates) > 0) { // Add the trend and utilization values to the savings plan object // This makes it easier to path to in the export @@ -326,7 +326,7 @@ script "js_filtered_savings_plans", type: "javascript" do utilization_aggregate = _.find(sp.utilization.aggregates, function(agg) { return agg.grain == param_lookback_days }) - + if (utilization_aggregate != undefined) { sp["utilizationAmount"] = utilization_aggregate.value sp["utilizationAmountUnit"] = utilization_aggregate.valueUnit @@ -334,7 +334,7 @@ script "js_filtered_savings_plans", type: "javascript" do sp = _.omit(sp, "utilization") } - + return sp }) EOS @@ -352,21 +352,27 @@ script "js_sp_data_for_incident", type: "javascript" do // function for formatting spend number function formatNumber(number, separator) { - var numString = number.toString(); - var values = numString.split("."); - var result = '' - while ( values[0].length > 3 ) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - result = separator + chunk + result - } - if ( values[0].length > 0 ) { - result = values[0] + result - } - if ( values[1] == undefined ) { - return result; + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } } - return result + "." + values[1]; + + return formatted_number } // format costs with currency symbol and thousands separator @@ -401,12 +407,12 @@ script "js_sp_data_for_incident", type: "javascript" do if (sp.commitmentAmount && sp.commitmentAmount != null) { total_wastage += Number(sp.commitmentAmount) } - + sp["policyName"] = ds_applied_policy.name }) total_wastage = cur + " " + formatNumber((Math.round(total_wastage * 100) / 100), separator) - + result = { "savings_plan_details": filtered_sps, "message": "The total estimated hourly wasted spend is " + total_wastage diff --git a/cost/azure/superseded_instances/CHANGELOG.md b/cost/azure/superseded_instances/CHANGELOG.md index f129f67564..cca47c0047 100644 --- a/cost/azure/superseded_instances/CHANGELOG.md +++ b/cost/azure/superseded_instances/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v2.1.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v2.1.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/azure/superseded_instances/azure_superseded_instances.pt b/cost/azure/superseded_instances/azure_superseded_instances.pt index cdba31ddc8..b6d355a418 100644 --- a/cost/azure/superseded_instances/azure_superseded_instances.pt +++ b/cost/azure/superseded_instances/azure_superseded_instances.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "2.1.1", + version: "2.1.2", provider: "Azure", service: "Compute", policy_set: "Superseded Compute Instances", @@ -694,21 +694,28 @@ script "js_superseded_instances", type: "javascript" do result "result" code <<-'EOS' // Used for formatting numbers to look pretty - function formatNumber(number, separator){ - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/unused_app_service_plans/CHANGELOG.md b/cost/azure/unused_app_service_plans/CHANGELOG.md index a1ed544621..8974b46b62 100644 --- a/cost/azure/unused_app_service_plans/CHANGELOG.md +++ b/cost/azure/unused_app_service_plans/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.1.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.1.0 - Initial release diff --git a/cost/azure/unused_app_service_plans/azure_unused_app_service_plans.pt b/cost/azure/unused_app_service_plans/azure_unused_app_service_plans.pt index e4836b741d..239bef5668 100644 --- a/cost/azure/unused_app_service_plans/azure_unused_app_service_plans.pt +++ b/cost/azure/unused_app_service_plans/azure_unused_app_service_plans.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.1.0", + version: "0.1.1", provider: "Azure", service: "PaaS", policy_set: "PaaS Optimization", @@ -582,21 +582,27 @@ script "js_bad_azure_app_service_plans", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } bad_app_service_plans = _.reject(ds_azure_app_service_plans_region_filtered, function(app_service_plan) { diff --git a/cost/azure/unused_firewalls/CHANGELOG.md b/cost/azure/unused_firewalls/CHANGELOG.md index 017523f544..0988839fc6 100644 --- a/cost/azure/unused_firewalls/CHANGELOG.md +++ b/cost/azure/unused_firewalls/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.2.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.2.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/azure/unused_firewalls/azure_unused_firewalls.pt b/cost/azure/unused_firewalls/azure_unused_firewalls.pt index ff3996b71f..0087474713 100644 --- a/cost/azure/unused_firewalls/azure_unused_firewalls.pt +++ b/cost/azure/unused_firewalls/azure_unused_firewalls.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.2.1", + version: "0.2.2", provider: "Azure", service: "Network", policy_set: "Unused Firewalls", @@ -680,21 +680,27 @@ script "js_azure_unused_firewalls_incident", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/unused_ip_addresses/CHANGELOG.md b/cost/azure/unused_ip_addresses/CHANGELOG.md index d5821e9b6b..f212ecefec 100644 --- a/cost/azure/unused_ip_addresses/CHANGELOG.md +++ b/cost/azure/unused_ip_addresses/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v7.3.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v7.3.0 - Modified internal names for incident fields for more accurate scraping into Optimization dashboard diff --git a/cost/azure/unused_ip_addresses/azure_unused_ip_addresses.pt b/cost/azure/unused_ip_addresses/azure_unused_ip_addresses.pt index f0335dd4de..f2e2a7eefc 100644 --- a/cost/azure/unused_ip_addresses/azure_unused_ip_addresses.pt +++ b/cost/azure/unused_ip_addresses/azure_unused_ip_addresses.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "7.3.0", + version: "7.3.1", provider: "Azure", service: "Compute", policy_set: "Unused IP Addresses", @@ -709,21 +709,27 @@ script "js_ip_cost_mapping", type:"javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/unused_load_balancers/CHANGELOG.md b/cost/azure/unused_load_balancers/CHANGELOG.md index 74a3156afd..4d4ad3e086 100644 --- a/cost/azure/unused_load_balancers/CHANGELOG.md +++ b/cost/azure/unused_load_balancers/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.1.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.1.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/azure/unused_load_balancers/azure_unused_load_balancers.pt b/cost/azure/unused_load_balancers/azure_unused_load_balancers.pt index e82db3a405..2f41c7b5d5 100644 --- a/cost/azure/unused_load_balancers/azure_unused_load_balancers.pt +++ b/cost/azure/unused_load_balancers/azure_unused_load_balancers.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.1.1", + version: "0.1.2", provider: "Azure", service: "Network", policy_set: "Unused Load Balancers", @@ -701,21 +701,27 @@ script "js_azure_unused_loadbalancers_incident", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/azure/unused_volumes/CHANGELOG.md b/cost/azure/unused_volumes/CHANGELOG.md index 0f4febe74e..21fd6f7939 100644 --- a/cost/azure/unused_volumes/CHANGELOG.md +++ b/cost/azure/unused_volumes/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v8.2.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v8.2.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/azure/unused_volumes/azure_unused_volumes.pt b/cost/azure/unused_volumes/azure_unused_volumes.pt index f8029385b0..3118d1d63b 100644 --- a/cost/azure/unused_volumes/azure_unused_volumes.pt +++ b/cost/azure/unused_volumes/azure_unused_volumes.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "8.2.1", + version: "8.2.2", provider: "Azure", service: "Storage", policy_set: "Unused Volumes", @@ -757,21 +757,27 @@ script "js_volume_cost_mapping", type:"javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/flexera/cco/forecasting/commitment_forecast/CHANGELOG.md b/cost/flexera/cco/forecasting/commitment_forecast/CHANGELOG.md index fc7e6e6446..c2962f5835 100644 --- a/cost/flexera/cco/forecasting/commitment_forecast/CHANGELOG.md +++ b/cost/flexera/cco/forecasting/commitment_forecast/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v4.0.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v4.0.0 - Renamed policy template to `Vendor Spend Commitment Forecast` to avoid confusion with policy templates for RIs/SPs diff --git a/cost/flexera/cco/forecasting/commitment_forecast/commitment_forecast.pt b/cost/flexera/cco/forecasting/commitment_forecast/commitment_forecast.pt index ef0410ba9a..1f5ce8f479 100644 --- a/cost/flexera/cco/forecasting/commitment_forecast/commitment_forecast.pt +++ b/cost/flexera/cco/forecasting/commitment_forecast/commitment_forecast.pt @@ -7,7 +7,7 @@ category "Cost" severity "medium" default_frequency "monthly" info( - version: "4.0.0", + version: "4.0.1", provider: "Flexera", service: "Cloud Cost Optimization", policy_set: "Forecasting" @@ -333,20 +333,27 @@ script "js_chart_data", type: "javascript" do code <<-'EOS' // Used for formatting numbers to look pretty function formatNumber(number, separator) { - numString = number.toString() - values = numString.split(".") - formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } fmt_actual_spend = ds_forecasted_spend['currency'] + formatNumber(ds_forecasted_spend['actual_spend'], ds_forecasted_spend['currency_sep']) diff --git a/cost/flexera/cco/new_usage/CHANGELOG.md b/cost/flexera/cco/new_usage/CHANGELOG.md index a2ec42ff51..d03dd606f8 100644 --- a/cost/flexera/cco/new_usage/CHANGELOG.md +++ b/cost/flexera/cco/new_usage/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v3.0.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v3.0.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/flexera/cco/new_usage/new_usage.pt b/cost/flexera/cco/new_usage/new_usage.pt index 7f15a13af3..1d3d4b8f13 100644 --- a/cost/flexera/cco/new_usage/new_usage.pt +++ b/cost/flexera/cco/new_usage/new_usage.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "daily" info( - version: "3.0.1", + version: "3.0.2", provider: "Flexera", service: "Cloud Cost Optimization", policy_set: "Cloud Cost Optimization" @@ -324,21 +324,27 @@ script "js_new_usage", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } cost_metric_table = { diff --git a/cost/flexera/msp/master_org_cost_policy/CHANGELOG.md b/cost/flexera/msp/master_org_cost_policy/CHANGELOG.md index c3471afa41..5c029b11cb 100644 --- a/cost/flexera/msp/master_org_cost_policy/CHANGELOG.md +++ b/cost/flexera/msp/master_org_cost_policy/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v2.0.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v2.0.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/flexera/msp/master_org_cost_policy/master_org_cost_policy.pt b/cost/flexera/msp/master_org_cost_policy/master_org_cost_policy.pt index 38563934d9..f84beba48e 100644 --- a/cost/flexera/msp/master_org_cost_policy/master_org_cost_policy.pt +++ b/cost/flexera/msp/master_org_cost_policy/master_org_cost_policy.pt @@ -16,7 +16,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "2.0.1", + version: "2.0.2", provider: "Flexera", service: "Cloud Cost Optimization", policy_set: "Managed Service Provider", @@ -616,22 +616,30 @@ script "js_report", type: "javascript" do monthly_change = Number(( current_month_total - previous_month_total) / previous_month_total * 100).toFixed(1) } - function formatNumber(number, separator) - { - var numString = number.toString() - var result = '' - while (numString.length > 3) - { - var chunk = numString.substr(-3) - numString = numString.substr(0, numString.length - 3) - result = separator + chunk + result - } - if (numString.length > 0) - { - result = numString + result + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } } - return result + + return formatted_number } + // Format costs with currency symbol and thousands separator if( ds_currency_code['value'] !== undefined ) { if (ds_currency_reference[ds_currency_code['value']] !== undefined ) { diff --git a/cost/flexera/msp/master_org_cost_policy_currency/CHANGELOG.md b/cost/flexera/msp/master_org_cost_policy_currency/CHANGELOG.md index 9610513da0..602f2a88e6 100644 --- a/cost/flexera/msp/master_org_cost_policy_currency/CHANGELOG.md +++ b/cost/flexera/msp/master_org_cost_policy_currency/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v2.0.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v2.0.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/flexera/msp/master_org_cost_policy_currency/master_org_cost_policy_currency.pt b/cost/flexera/msp/master_org_cost_policy_currency/master_org_cost_policy_currency.pt index 51b1448f00..6bf7c6e96a 100644 --- a/cost/flexera/msp/master_org_cost_policy_currency/master_org_cost_policy_currency.pt +++ b/cost/flexera/msp/master_org_cost_policy_currency/master_org_cost_policy_currency.pt @@ -16,7 +16,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "2.0.1", + version: "2.0.2", provider: "Flexera", service: "Cloud Cost Optimization", policy_set: "Managed Service Provider", @@ -606,21 +606,28 @@ script "js_report", type: "javascript" do parameters "ds_current_week_costs", "ds_previous_week_costs", "ds_current_month_costs", "ds_previous_month_costs", "ds_currency_code", "ds_currency_reference", "ds_currency_conversion", "ds_filtered_user_organizations", "param_final_currency", "param_cost_metric" result "report" code <<-EOS - function formatNumber(number, separator) - { - var numString = number.toString() - var result = '' - while (numString.length > 3) - { - var chunk = numString.substr(-3) - numString = numString.substr(0, numString.length - 3) - result = separator + chunk + result - } - if (numString.length > 0) - { - result = numString + result + function formatNumber(number, separator) { + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } + + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } } - return result + + return formatted_number } // create a map to use in the request metric field. diff --git a/cost/google/cud_recommendations/CHANGELOG.md b/cost/google/cud_recommendations/CHANGELOG.md index 7841f00034..6003248139 100644 --- a/cost/google/cud_recommendations/CHANGELOG.md +++ b/cost/google/cud_recommendations/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v4.2.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v4.2.1 - Added `Service` field to incident table diff --git a/cost/google/cud_recommendations/google_committed_use_discount_recommendations.pt b/cost/google/cud_recommendations/google_committed_use_discount_recommendations.pt index 0cef086ab2..9ba3065732 100644 --- a/cost/google/cud_recommendations/google_committed_use_discount_recommendations.pt +++ b/cost/google/cud_recommendations/google_committed_use_discount_recommendations.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "4.2.1", + version: "4.2.2", provider: "Google", service: "Compute", recommendation_type: "Rate Reduction", @@ -418,21 +418,27 @@ script "js_recommendations_incident", type:"javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } algorithm_table = { diff --git a/cost/google/idle_ip_address_recommendations/CHANGELOG.md b/cost/google/idle_ip_address_recommendations/CHANGELOG.md index fd80b65491..bad382ff83 100644 --- a/cost/google/idle_ip_address_recommendations/CHANGELOG.md +++ b/cost/google/idle_ip_address_recommendations/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v4.2.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v4.2.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/google/idle_ip_address_recommendations/google_idle_ip_address_recommendations.pt b/cost/google/idle_ip_address_recommendations/google_idle_ip_address_recommendations.pt index a379f86087..bda26c0ec2 100644 --- a/cost/google/idle_ip_address_recommendations/google_idle_ip_address_recommendations.pt +++ b/cost/google/idle_ip_address_recommendations/google_idle_ip_address_recommendations.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "4.2.1", + version: "4.2.2", provider: "Google", service: "Compute", policy_set: "Unused IP Addresses", @@ -525,21 +525,27 @@ script "js_recommendations_incident", type:"javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } address_object = {} diff --git a/cost/google/idle_persistent_disk_recommendations/CHANGELOG.md b/cost/google/idle_persistent_disk_recommendations/CHANGELOG.md index 36f40f4120..b5f37e8b94 100644 --- a/cost/google/idle_persistent_disk_recommendations/CHANGELOG.md +++ b/cost/google/idle_persistent_disk_recommendations/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v4.2.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v4.2.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/google/idle_persistent_disk_recommendations/google_idle_persistent_disk_recommendations.pt b/cost/google/idle_persistent_disk_recommendations/google_idle_persistent_disk_recommendations.pt index dc2327f085..211967a4ef 100644 --- a/cost/google/idle_persistent_disk_recommendations/google_idle_persistent_disk_recommendations.pt +++ b/cost/google/idle_persistent_disk_recommendations/google_idle_persistent_disk_recommendations.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "4.2.1", + version: "4.2.2", provider: "Google", service: "Storage", policy_set: "Unused Volumes", @@ -767,21 +767,27 @@ script "js_recommendations_incident", type:"javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } disks_object = {} diff --git a/cost/google/old_snapshots/CHANGELOG.md b/cost/google/old_snapshots/CHANGELOG.md index e6c53b8f63..719deb1e41 100644 --- a/cost/google/old_snapshots/CHANGELOG.md +++ b/cost/google/old_snapshots/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v5.1.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v5.1.0 - Modified internal names for incident fields for more accurate scraping into Optimization dashboard diff --git a/cost/google/old_snapshots/google_delete_old_snapshots.pt b/cost/google/old_snapshots/google_delete_old_snapshots.pt index 32d5b53f28..961c7c9df9 100644 --- a/cost/google/old_snapshots/google_delete_old_snapshots.pt +++ b/cost/google/old_snapshots/google_delete_old_snapshots.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "5.1.0", + version: "5.1.1", provider:"Google", service: "Storage", policy_set: "Old Snapshots", @@ -885,21 +885,27 @@ script "js_google_old_snapshots_incident", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } // [].concat is to make sure we genuinely create a new list diff --git a/cost/google/recommender/CHANGELOG.md b/cost/google/recommender/CHANGELOG.md index 3eabd15ea0..418b6ddc3e 100644 --- a/cost/google/recommender/CHANGELOG.md +++ b/cost/google/recommender/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v3.0.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v3.0.1 - Fixed issue with meta policy failing during execution due to order of fields in incident diff --git a/cost/google/recommender/recommender.pt b/cost/google/recommender/recommender.pt index 45386780a1..b429cec46e 100644 --- a/cost/google/recommender/recommender.pt +++ b/cost/google/recommender/recommender.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "3.0.1", + version: "3.0.2", provider: "Google", service: "All", policy_set: "Native Recommendations" @@ -424,21 +424,27 @@ script "js_recommendations_incident", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/cost/google/rightsize_cloudsql_recommendations/CHANGELOG.md b/cost/google/rightsize_cloudsql_recommendations/CHANGELOG.md index a1ed544621..8974b46b62 100644 --- a/cost/google/rightsize_cloudsql_recommendations/CHANGELOG.md +++ b/cost/google/rightsize_cloudsql_recommendations/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.1.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.1.0 - Initial release diff --git a/cost/google/rightsize_cloudsql_recommendations/google_rightsize_cloudsql_recommendations.pt b/cost/google/rightsize_cloudsql_recommendations/google_rightsize_cloudsql_recommendations.pt index e80e0e24bd..e3e97d6b17 100644 --- a/cost/google/rightsize_cloudsql_recommendations/google_rightsize_cloudsql_recommendations.pt +++ b/cost/google/rightsize_cloudsql_recommendations/google_rightsize_cloudsql_recommendations.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.1.0", + version: "0.1.1", provider: "Google", service: "Compute", policy_set: "Rightsize Database Instances", @@ -796,21 +796,27 @@ script "js_idle_incident", type:"javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } // Sort by descending order of savings value @@ -899,21 +905,27 @@ script "js_underutil_incident", type:"javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } // Sort by descending order of savings value diff --git a/cost/google/rightsize_vm_recommendations/CHANGELOG.md b/cost/google/rightsize_vm_recommendations/CHANGELOG.md index 722ec0508b..0774ee6f38 100644 --- a/cost/google/rightsize_vm_recommendations/CHANGELOG.md +++ b/cost/google/rightsize_vm_recommendations/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v3.1.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v3.1.1 - Idle VM Instances incident now includes a `Recommended Resource Type` field with a value of `Delete VM Instance` for ease of analyzing recommendations from the Flexera Optimization dashboard diff --git a/cost/google/rightsize_vm_recommendations/google_rightsize_vm_recommendations.pt b/cost/google/rightsize_vm_recommendations/google_rightsize_vm_recommendations.pt index 97274099f8..aaaa396408 100644 --- a/cost/google/rightsize_vm_recommendations/google_rightsize_vm_recommendations.pt +++ b/cost/google/rightsize_vm_recommendations/google_rightsize_vm_recommendations.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "3.1.1", + version: "3.1.2", provider: "Google", service: "Compute", policy_set: "Rightsize Compute Instances", @@ -972,21 +972,27 @@ script "js_idle_incident", type:"javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } // Sort by descending order of savings value @@ -1075,21 +1081,27 @@ script "js_underutil_incident", type:"javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + if (separator) { + withSeparator = "" + + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } // Sort by descending order of savings value diff --git a/cost/kubecost/cluster/CHANGELOG.md b/cost/kubecost/cluster/CHANGELOG.md index 6aa2d57ab8..859cc55ab4 100644 --- a/cost/kubecost/cluster/CHANGELOG.md +++ b/cost/kubecost/cluster/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.3.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.3.0 - Policy template renamed to `Kubecost Cluster Rightsizing Recommendation` to better reflect its functionality diff --git a/cost/kubecost/cluster/kubecost_cluster_rightsizing_recommendations.pt b/cost/kubecost/cluster/kubecost_cluster_rightsizing_recommendations.pt index abfcc7261e..11ab7e887f 100644 --- a/cost/kubecost/cluster/kubecost_cluster_rightsizing_recommendations.pt +++ b/cost/kubecost/cluster/kubecost_cluster_rightsizing_recommendations.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.3.0", + version: "0.3.1", provider: "Kubecost", service: "Kubernetes", policy_set: "Rightsize Clusters", @@ -193,21 +193,27 @@ script "js_recommendations", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } selected_strategy = param_strategy diff --git a/cost/kubecost/sizing/CHANGELOG.md b/cost/kubecost/sizing/CHANGELOG.md index 6039f108a8..f951befdc8 100644 --- a/cost/kubecost/sizing/CHANGELOG.md +++ b/cost/kubecost/sizing/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.4.1 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.4.0 - Policy template renamed to `Kubecost Container Request Rightsizing Recommendations` to better reflect its functionality diff --git a/cost/kubecost/sizing/kubecost_resizing_recommendation.pt b/cost/kubecost/sizing/kubecost_resizing_recommendation.pt index 948aa7de09..ad1ed75e8d 100644 --- a/cost/kubecost/sizing/kubecost_resizing_recommendation.pt +++ b/cost/kubecost/sizing/kubecost_resizing_recommendation.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "0.4.0", + version: "0.4.1", provider: "Kubecost", service: "Kubernetes", policy_set: "Rightsize Containers", @@ -298,21 +298,27 @@ script "js_recommendations", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } cluster_table = {} diff --git a/operational/aws/marketplace_new_products/CHANGELOG.md b/operational/aws/marketplace_new_products/CHANGELOG.md index bb6449a49f..f36b82caf1 100644 --- a/operational/aws/marketplace_new_products/CHANGELOG.md +++ b/operational/aws/marketplace_new_products/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.3.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.3.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/operational/aws/marketplace_new_products/aws_marketplace_new_products.pt b/operational/aws/marketplace_new_products/aws_marketplace_new_products.pt index 61b8cc9512..0f1e6e0aab 100644 --- a/operational/aws/marketplace_new_products/aws_marketplace_new_products.pt +++ b/operational/aws/marketplace_new_products/aws_marketplace_new_products.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "0.3.1", + version: "0.3.2", provider: "AWS", service: "Marketplace", policy_set: "New Marketplace Products" @@ -236,21 +236,27 @@ script "js_new_products", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = [] diff --git a/operational/azure/marketplace_new_products/CHANGELOG.md b/operational/azure/marketplace_new_products/CHANGELOG.md index 73cac24452..b054eef7bc 100644 --- a/operational/azure/marketplace_new_products/CHANGELOG.md +++ b/operational/azure/marketplace_new_products/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.4.2 + +- Fixed issue with numeric currency values sometimes showing 'undefined' instead of currency separators + ## v0.4.1 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/operational/azure/marketplace_new_products/azure_marketplace_new_products.pt b/operational/azure/marketplace_new_products/azure_marketplace_new_products.pt index 79e04863bf..84fa9003ee 100644 --- a/operational/azure/marketplace_new_products/azure_marketplace_new_products.pt +++ b/operational/azure/marketplace_new_products/azure_marketplace_new_products.pt @@ -7,7 +7,7 @@ severity "low" category "Cost" default_frequency "weekly" info( - version: "0.4.1", + version: "0.4.2", provider: "Azure", service: "Marketplace", policy_set: "New Marketplace Products" @@ -434,21 +434,27 @@ script "js_new_products", type: "javascript" do code <<-'EOS' // Function for formatting currency numbers later function formatNumber(number, separator) { - var numString = number.toString() - var values = numString.split(".") - var formatted_number = '' - - while (values[0].length > 3) { - var chunk = values[0].substr(-3) - values[0] = values[0].substr(0, values[0].length - 3) - formatted_number = separator + chunk + formatted_number - } + formatted_number = "0" + + if (number) { + formatted_number = (Math.round(number * 100) / 100).toString().split(".")[0] + + if (separator) { + withSeparator = "" - if (values[0].length > 0) { formatted_number = values[0] + formatted_number } + for (var i = 0; i < formatted_number.length; i++) { + if (i > 0 && (formatted_number.length - i) % 3 == 0) { withSeparator += separator } + withSeparator += formatted_number[i] + } - if (values[1] == undefined) { return formatted_number } + formatted_number = withSeparator + } + + decimal = (Math.round(number * 100) / 100).toString().split(".")[1] + if (decimal) { formatted_number += "." + decimal } + } - return formatted_number + "." + values[1] + return formatted_number } result = []