Skip to content

Commit

Permalink
fix: display a dash when net positive is not reached (#20)
Browse files Browse the repository at this point in the history
* fix: display a dash when net positive is not reached

* chore: spabs
  • Loading branch information
shanehull authored Nov 13, 2024
1 parent 011caef commit 42ef5e8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 59 deletions.
7 changes: 0 additions & 7 deletions internal/templates/Blank.templ

This file was deleted.

37 changes: 0 additions & 37 deletions internal/templates/Blank_templ.go

This file was deleted.

9 changes: 5 additions & 4 deletions internal/templates/metrics.templ
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package templates

import (
"fmt"
"strconv"
"golang.org/x/text/language"
"golang.org/x/text/message"

Expand All @@ -10,13 +11,13 @@ import (

var firstPositive = -1

func getFirstPositiveYear(data []float64) int {
func getFirstPositiveYear(data []float64) string {
for i, value := range data {
if value > 0 {
return i+1
return strconv.Itoa(i+1)
}
}
return -1
return ""
}

func getYearsIndex(numYears int) int {
Expand Down Expand Up @@ -69,7 +70,7 @@ templ metrics(data *calc.Data, params *calc.Parameters) {
</span>
Net Positive In:
</strong>
{ fmt.Sprintf("%d years", getFirstPositiveYear(data.NetPosition)) }
{ fmt.Sprintf("%s years", getFirstPositiveYear(data.NetPosition)) }
</li>
<li>
<strong>
Expand Down
23 changes: 12 additions & 11 deletions internal/templates/metrics_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 42ef5e8

Please sign in to comment.