Skip to content

Commit

Permalink
POL-1413 Currency Separator Fix (#2818)
Browse files Browse the repository at this point in the history
* update

* fix

* update

* fix

* update

* fix

* update

* update

* update

* update

* update
  • Loading branch information
XOmniverse authored Nov 11, 2024
1 parent 2521880 commit d8cd7a3
Show file tree
Hide file tree
Showing 114 changed files with 1,497 additions and 866 deletions.
4 changes: 4 additions & 0 deletions cost/aws/ec2_compute_optimizer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
35 changes: 21 additions & 14 deletions cost/aws/ec2_compute_optimizer/aws_ec2_compute_optimizer.pt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 = {}
Expand Down
4 changes: 4 additions & 0 deletions cost/aws/extended_support/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
35 changes: 21 additions & 14 deletions cost/aws/extended_support/aws_extended_support.pt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions cost/aws/idle_nat_gateways/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
35 changes: 21 additions & 14 deletions cost/aws/idle_nat_gateways/aws_idle_nat_gateways.pt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 = []
Expand Down
4 changes: 4 additions & 0 deletions cost/aws/old_snapshots/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
32 changes: 19 additions & 13 deletions cost/aws/old_snapshots/aws_delete_old_snapshots.pt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 = []
Expand Down
4 changes: 4 additions & 0 deletions cost/aws/reserved_instances/recommendations/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 = []
Expand Down
4 changes: 4 additions & 0 deletions cost/aws/rightsize_ebs_volumes/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
35 changes: 21 additions & 14 deletions cost/aws/rightsize_ebs_volumes/aws_rightsize_ebs_volumes.pt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions cost/aws/rightsize_ec2_instances/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Loading

0 comments on commit d8cd7a3

Please sign in to comment.