Skip to content

Commit

Permalink
1.7.1 (#15)
Browse files Browse the repository at this point in the history
* Set cache clean up time to cacheTTL if it's less than an hour

* Fix life fame calculation formula

* Bump version number
  • Loading branch information
man90es authored May 9, 2024
1 parent df9a12b commit 978b8c8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewCache[T any]() *cache[T] {
cacheTTL := config.GetCacheTTL()

return &cache[T]{
internalCache: goCache.New(cacheTTL, time.Hour),
internalCache: goCache.New(cacheTTL, min(time.Hour, cacheTTL)),
}
}

Expand Down
2 changes: 1 addition & 1 deletion handlers/GetStatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ func GetStatus(w http.ResponseWriter, r *http.Request) {
},
"proxies": len(config.GetProxyList()),
"uptime": time.Since(initTime).Round(time.Second).String(),
"version": "1.7.0",
"version": "1.7.1",
})
}
2 changes: 1 addition & 1 deletion utils/CalculateLifeFame.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func CalculateLifeFame(specs [11]string) (lifeFame uint16) {
} else if text == "Master" {
lifeFame += 150 + uint16(number)*3
} else if text == "Guru" {
lifeFame += 253
lifeFame += 240 + uint16(number)*3
}
}

Expand Down
32 changes: 32 additions & 0 deletions utils/CalculateLifeFame_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package utils

import (
"testing"
)

func TestCalculateLifeFame(t *testing.T) {
tests := []struct {
input [11]string
expected uint16
}{
{
input: [11]string{"Artisan 6", "Professional 4", "Artisan 1", "Master 6", "Professional 7", "Artisan 8", "Professional 10", "Apprentice 9", "Skilled 4", "Apprentice 4", "Beginner 1"},
expected: 907,
},
{
input: [11]string{"Guru 7", "Skilled 5", "Beginner 8", "Guru 52", "Guru 27", "Guru 35", "Artisan 3", "Apprentice 7", "Guru 15", "Geginner 6", "Beginner 1"},
expected: 1738,
},
{
input: [11]string{"Beginner 1", "Beginner 1", "Beginner 1", "Beginner 1", "Beginner 1", "Beginner 1", "Beginner 1", "Beginner 1", "Beginner 1", "Beginner 1", "Beginner 1"},
expected: 1,
},
}

for _, test := range tests {
result := CalculateLifeFame(test.input)
if result != test.expected {
t.Errorf("Input: %v, Expected: %v, Got: %v", test.input, test.expected, result)
}
}
}

0 comments on commit 978b8c8

Please sign in to comment.