Skip to content

Commit

Permalink
Update sub-item template
Browse files Browse the repository at this point in the history
We use a unicode whitespace as Odoo does not render normal spaces and
and will escape  
  • Loading branch information
glrf committed May 10, 2022
1 parent a9a7328 commit f6a655b
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 31 deletions.
11 changes: 11 additions & 0 deletions description_templates/_compute.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{template "_compute" . -}}
{{- define "_compute" -}}
{{$s:="\u2001"}}{{/*We need to use unicode whitespaces to make Odoo render them*/}}
Compute

Qty: {{.Quantity | printf "%.2f"}} {{.Unit}}-Minutes
Average Usage: {{.QuantityAvg | perMinute | printf "%.2f"}} {{.Unit}} / Minute
{{$s}}Memory Requests: {{.SubItems.appuio_cloud_memory_subquery_memory_request.QuantityAvg | perMinute | printf "%.2f"}} {{.Unit}} / Minute
{{$s}}CPU Requests: {{.SubItems.appuio_cloud_memory_subquery_cpu_request.QuantityAvg | perMinute | printf "%.2f"}} {{.Unit}} / Minute
Unit Price: CHF {{.PricePerUnit | printf "%.10f"}} / {{.Unit}} / Minute
{{- end -}}
3 changes: 0 additions & 3 deletions description_templates/_usage.gotmpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{{- define "_usage" -}}
Qty: {{.Quantity | printf "%.2f"}} {{.Unit}}-Minutes
Average Usage: {{.QuantityAvg | perMinute | printf "%.2f"}} {{.Unit}} / Minute
{{ range .SubItems -}}
Average {{.Description}}: {{.QuantityAvg | perMinute | printf "%.2f"}} {{.Unit}} / Minute
{{ end -}}
Unit Price: CHF {{.PricePerUnit | printf "%.10f"}} / {{.Unit}} / Minute
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
Compute

{{template "_usage" . -}}
{{template "_compute" . -}}
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
Compute

{{template "_usage" . -}}
{{template "_compute" . -}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ Service Type LoadBalancer

Qty: 87955674.09 UNIT-Minutes
Average Usage: 7.61 UNIT / Minute
Average Memory requests: 0.70 TPS / Minute
Average CPU requests in memory request equivalent: 0.70 TPS / Minute
Unit Price: CHF 0.0000007460 / UNIT / Minute
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ Service Type LoadBalancer

Qty: 87955674.09 UNIT-Minutes
Average Usage: 7.61 UNIT / Minute
Average Memory requests: 0.70 TPS / Minute
Average CPU requests in memory request equivalent: 0.70 TPS / Minute
Unit Price: CHF 0.0000007460 / UNIT / Minute

Services of type LoadBalancer are not supported on "Exoscale - CH-GVA-2 0".
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

Compute

Qty: 87955674.09 UNIT-Minutes
Average Usage: 7.61 UNIT / Minute
Average Memory requests: 0.70 TPS / Minute
Average CPU requests in memory request equivalent: 0.70 TPS / Minute
Memory Requests: 0.70 UNIT / Minute
CPU Requests: 0.70 UNIT / Minute
Unit Price: CHF 0.0000007460 / UNIT / Minute
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@

Compute

Qty: 87955674.09 UNIT-Minutes
Average Usage: 7.61 UNIT / Minute
Average Memory requests: 0.70 TPS / Minute
Average CPU requests in memory request equivalent: 0.70 TPS / Minute
Memory Requests: 0.70 UNIT / Minute
CPU Requests: 0.70 UNIT / Minute
Unit Price: CHF 0.0000007460 / UNIT / Minute
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ Persistent Storage
Storage Type: RWO [bulk]
Qty: 87955674.09 UNIT-Minutes
Average Usage: 7.61 UNIT / Minute
Average Memory requests: 0.70 TPS / Minute
Average CPU requests in memory request equivalent: 0.70 TPS / Minute
Unit Price: CHF 0.0000007460 / UNIT / Minute
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ Persistent Storage
Storage Type: RWX [cephfs-fspool-cluster]
Qty: 87955674.09 UNIT-Minutes
Average Usage: 7.61 UNIT / Minute
Average Memory requests: 0.70 TPS / Minute
Average CPU requests in memory request equivalent: 0.70 TPS / Minute
Unit Price: CHF 0.0000007460 / UNIT / Minute
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ Persistent Storage
Storage Type: RWO [ssd]
Qty: 87955674.09 UNIT-Minutes
Average Usage: 7.61 UNIT / Minute
Average Memory requests: 0.70 TPS / Minute
Average CPU requests in memory request equivalent: 0.70 TPS / Minute
Unit Price: CHF 0.0000007460 / UNIT / Minute
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ Persistent Storage
Storage Type: RWX [cephfs-fspool-cluster]
Qty: 87955674.09 UNIT-Minutes
Average Usage: 7.61 UNIT / Minute
Average Memory requests: 0.70 TPS / Minute
Average CPU requests in memory request equivalent: 0.70 TPS / Minute
Unit Price: CHF 0.0000007460 / UNIT / Minute
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ Persistent Storage
Storage Type: RWO [rbd-storagepool-cluster]
Qty: 87955674.09 UNIT-Minutes
Average Usage: 7.61 UNIT / Minute
Average Memory requests: 0.70 TPS / Minute
Average CPU requests in memory request equivalent: 0.70 TPS / Minute
Unit Price: CHF 0.0000007460 / UNIT / Minute
11 changes: 7 additions & 4 deletions description_templates/golden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func TestGenerateGolden(t *testing.T) {

baseItem := invoice.Item{
Description: "Long form query description",
QueryName: "default_query",
ProductRef: invoice.ProductRef{
Target: "1919",
Source: "SET ME",
Expand All @@ -59,17 +60,19 @@ func TestGenerateGolden(t *testing.T) {
PricePerUnit: 0.000000746,
Discount: 0.33,
Total: 43.962005025946798,
SubItems: []invoice.SubItem{
{
Description: "Memory requests",
SubItems: map[string]invoice.SubItem{
"appuio_cloud_memory_subquery_memory_request": {
Description: "Memory request aggregated by namespace",
QueryName: "appuio_cloud_memory_subquery_memory_request",
Quantity: 34923234.04433424,
QuantityMin: 2.251,
QuantityAvg: 42.2,
QuantityMax: 9001.1,
Unit: "TPS",
},
{
"appuio_cloud_memory_subquery_cpu_request": {
Description: "CPU requests in memory request equivalent",
QueryName: "appuio_cloud_memory_subquery_cpu_request",
Quantity: 34923234.04433424,
QuantityMin: 2.251,
QuantityAvg: 42.2,
Expand Down

0 comments on commit f6a655b

Please sign in to comment.